aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2014-08-08 03:48:54 +0000
committerGlenn Adams <gadams@apache.org>2014-08-08 03:48:54 +0000
commite9f270cf3a274fc59917354d225ab0f57707b96a (patch)
treef53e72f6d820dd5dcef527b856d88beace0064dd
parent9feb56844650da39b4df4a161ce268a68f8c7ca6 (diff)
downloadxmlgraphics-fop-e9f270cf3a274fc59917354d225ab0f57707b96a.tar.gz
xmlgraphics-fop-e9f270cf3a274fc59917354d225ab0f57707b96a.zip
Fix 4-instance findbug warnings.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1616668 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--findbugs-exclude.xml20
-rw-r--r--src/java/org/apache/fop/afp/util/StringUtils.java4
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java17
-rw-r--r--src/java/org/apache/fop/fonts/substitute/FontQualifier.java2
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRenderer.java52
-rw-r--r--src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java23
-rw-r--r--src/java/org/apache/fop/render/ps/ImageEncoderPNG.java16
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java8
-rw-r--r--src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java4
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java7
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java4
14 files changed, 87 insertions, 83 deletions
diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml
index c11fdc732..2deaa263f 100644
--- a/findbugs-exclude.xml
+++ b/findbugs-exclude.xml
@@ -26,10 +26,6 @@
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
</Match>
<Match>
- <!-- 4 warnings -->
- <Bug pattern="DM_BOOLEAN_CTOR"/>
- </Match>
- <Match>
<!-- 29 warnings -->
<Bug pattern="DM_CONVERT_CASE"/>
</Match>
@@ -46,10 +42,6 @@
<Bug pattern="DM_NUMBER_CTOR"/>
</Match>
<Match>
- <!-- 4 warnings -->
- <Bug pattern="DM_STRING_VOID_CTOR"/>
- </Match>
- <Match>
<!-- 84 warnings -->
<Bug pattern="EI_EXPOSE_REP"/>
</Match>
@@ -112,18 +104,6 @@
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
</Match>
<Match>
- <!-- 4 warnings -->
- <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
- </Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="NP_NULL_ON_SOME_PATH"/>
- </Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="OS_OPEN_STREAM"/>
- </Match>
- <Match>
<!-- 46 warnings -->
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
</Match>
diff --git a/src/java/org/apache/fop/afp/util/StringUtils.java b/src/java/org/apache/fop/afp/util/StringUtils.java
index ab5d6013b..26dfc5c1a 100644
--- a/src/java/org/apache/fop/afp/util/StringUtils.java
+++ b/src/java/org/apache/fop/afp/util/StringUtils.java
@@ -39,7 +39,7 @@ public final class StringUtils {
public static String lpad(String input, char padding, int length) {
if (input == null) {
- input = new String();
+ input = "";
}
if (input.length() >= length) {
@@ -66,7 +66,7 @@ public final class StringUtils {
public static String rpad(String input, char padding, int length) {
if (input == null) {
- input = new String();
+ input = "";
}
if (input.length() >= length) {
diff --git a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
index 53b076073..bd506d9ed 100644
--- a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
@@ -25,6 +25,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
+import org.apache.commons.io.IOUtils;
+
/**
* FontFinder for native Windows platforms
*/
@@ -42,9 +44,18 @@ public class WindowsFontDirFinder implements FontDirFinder {
} else {
process = runtime.exec("cmd.exe /c echo %windir%");
}
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
- return bufferedReader.readLine();
+ InputStreamReader isr = null;
+ BufferedReader bufferedReader = null;
+ String dir = "";
+ try {
+ isr = new InputStreamReader(process.getInputStream());
+ bufferedReader = new BufferedReader(isr);
+ dir = bufferedReader.readLine();
+ } finally {
+ IOUtils.closeQuietly(bufferedReader);
+ IOUtils.closeQuietly(isr);
+ }
+ return dir;
}
/**
diff --git a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java b/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
index b7473d72f..8e9213e9d 100644
--- a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
+++ b/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
@@ -285,7 +285,7 @@ public class FontQualifier {
* {@inheritDoc}
*/
public String toString() {
- String str = new String();
+ String str = "";
if (fontFamilyAttributeValue != null) {
str += "font-family=" + fontFamilyAttributeValue;
}
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index 6f45d18ca..623b28618 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -118,11 +118,12 @@ public class PNGRenderer extends Java2DRenderer {
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Writing image using " + writer.getClass().getName());
+ }
+ writer.writeImage(image, os, params);
}
- if (log.isDebugEnabled()) {
- log.debug("Writing image using " + writer.getClass().getName());
- }
- writer.writeImage(image, os, params);
}
/**
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index 619d0625e..442660c3b 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -117,35 +117,35 @@ public class TIFFRenderer extends Java2DRenderer {
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
- }
- if (writer.supportsMultiImageWriter()) {
- MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
- try {
- // Write all pages/images
- while (pageImagesItr.hasNext()) {
- RenderedImage img = (RenderedImage) pageImagesItr.next();
- multiWriter.writeImage(img, imageSettings.getWriterParams());
- }
- } finally {
- multiWriter.close();
- }
} else {
- RenderedImage renderedImage = null;
- if (pageImagesItr.hasNext()) {
- renderedImage = (RenderedImage) pageImagesItr.next();
- }
- writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
- if (pageImagesItr.hasNext()) {
- BitmapRendererEventProducer eventProducer
- = BitmapRendererEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.stoppingAfterFirstPageNoFilename(this);
+ if (writer.supportsMultiImageWriter()) {
+ MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
+ try {
+ // Write all pages/images
+ while (pageImagesItr.hasNext()) {
+ RenderedImage img = (RenderedImage) pageImagesItr.next();
+ multiWriter.writeImage(img, imageSettings.getWriterParams());
+ }
+ } finally {
+ multiWriter.close();
+ }
+ } else {
+ RenderedImage renderedImage = null;
+ if (pageImagesItr.hasNext()) {
+ renderedImage = (RenderedImage) pageImagesItr.next();
+ }
+ writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
+ if (pageImagesItr.hasNext()) {
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.stoppingAfterFirstPageNoFilename(this);
+ }
}
+ // Cleaning
+ outputStream.flush();
+ clearViewportList();
}
-
- // Cleaning
- outputStream.flush();
- clearViewportList();
log.debug("TIFF encoding done.");
}
diff --git a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
index 5f69fbadb..f40ca6d94 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
@@ -119,13 +119,15 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
ByteArrayOutputStream baos = null;
DeflaterOutputStream dos = null;
InputStream in = null;
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
try {
baos = new ByteArrayOutputStream();
dos = new DeflaterOutputStream(baos, new Deflater());
in = ((ImageRawStream) image).createInputStream();
try {
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
// offset is the byte offset of the alpha component
int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA
int numColumns = image.getSize().getWidthPx();
@@ -159,12 +161,13 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
}
BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
image.getSize().getHeightPx(), baos.toByteArray(), null);
- IOUtils.closeQuietly(baos);
alphaMask.setPDFFilter(transFlate);
alphaMask.disallowMultipleFilters();
alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
softMask = doc.addImage(null, alphaMask).makeReference();
} finally {
+ IOUtils.closeQuietly(infStream);
+ IOUtils.closeQuietly(dataStream);
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(dos);
IOUtils.closeQuietly(baos);
@@ -216,7 +219,9 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
InputStream in = ((ImageRawStream) image).createInputStream();
-
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
+ DeflaterOutputStream dos = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
@@ -226,14 +231,14 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
// TODO: since we have alpha here do this when the alpha channel is extracted
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
int filter;
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha
// channel and then deflate the RGB channels back again
- DeflaterOutputStream dos = new DeflaterOutputStream(out, new Deflater());
+ dos = new DeflaterOutputStream(out, new Deflater());
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);
@@ -244,9 +249,11 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
}
offset = 0;
}
- dos.close();
}
} finally {
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(dataStream);
+ IOUtils.closeQuietly(infStream);
IOUtils.closeQuietly(in);
}
}
diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java b/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
index 5746a3fbe..8ab91cb0a 100644
--- a/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
+++ b/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
@@ -65,6 +65,10 @@ public class ImageEncoderPNG implements ImageEncoder {
public void writeTo(OutputStream out) throws IOException {
// TODO: refactor this code with equivalent PDF code
InputStream in = ((ImageRawStream) image).createInputStream();
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
+ ByteArrayOutputStream baos = null;
+ DeflaterOutputStream dos = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
@@ -73,8 +77,8 @@ public class ImageEncoderPNG implements ImageEncoder {
// means we have Gray + alpha or RGB + alpha
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
int filter;
@@ -83,8 +87,8 @@ public class ImageEncoderPNG implements ImageEncoder {
// TODO: not using the baos below and using the original out instead (as happens in PDF)
// would be preferable but that does not work with the rest of the postscript code; this
// needs to be revisited
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DeflaterOutputStream dos = new DeflaterOutputStream(/* out */baos, new Deflater());
+ baos = new ByteArrayOutputStream();
+ dos = new DeflaterOutputStream(/* out */baos, new Deflater());
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);
@@ -99,6 +103,10 @@ public class ImageEncoderPNG implements ImageEncoder {
IOUtils.copy(new ByteArrayInputStream(baos.toByteArray()), out);
}
} finally {
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(baos);
+ IOUtils.closeQuietly(dataStream);
+ IOUtils.closeQuietly(infStream);
IOUtils.closeQuietly(in);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
index 5013e0958..8dd58739c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
@@ -168,7 +168,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
}
//check for keep-together
- if (attrib != null && attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
+ if (attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
writeControlWord(ROW_KEEP_TOGETHER);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
index 0ee70bf31..fb590ab63 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
@@ -58,7 +58,7 @@ public final class ImageUtil {
* number The digits as integer
*/
public static int getInt(String value) {
- String retString = new String();
+ String retString = "";
StringBuffer s = new StringBuffer(value);
int len = s.length();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
index 85f1261f7..3e1aca1c1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
@@ -168,9 +168,9 @@ public class TableContext implements ITableColumnsInfo {
while (colIndex >= colFirstSpanningCol.size()) {
setNextFirstSpanningCol(false);
}
- colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.set(colIndex, Boolean.valueOf(bFirstSpanningCol));
} else {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
}
@@ -181,7 +181,7 @@ public class TableContext implements ITableColumnsInfo {
*/
public void setNextFirstSpanningCol(
boolean bFirstSpanningCol) {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
/**
@@ -202,7 +202,7 @@ public class TableContext implements ITableColumnsInfo {
if (i.intValue() == 0) {
colRowSpanningAttrs.set(z, null);
- colFirstSpanningCol.set(z, new Boolean(false));
+ colFirstSpanningCol.set(z, Boolean.valueOf(false));
}
}
}
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
index 6f2d4429d..a8e9307a7 100644
--- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
+++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
@@ -34,7 +34,6 @@ import org.apache.fop.fonts.DefaultFontConfigurator;
import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.FontCacheManagerFactory;
import org.apache.fop.fonts.FontDetectorFactory;
-import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontSetup;
@@ -97,12 +96,11 @@ public class PDFDocumentGraphics2DConfigurator {
//TODO Make use of fontBaseURL, font substitution and referencing configuration
//Requires a change to the expected configuration layout
- final FontEventListener listener = null;
DefaultFontConfig.DefaultFontConfigParser parser
= new DefaultFontConfig.DefaultFontConfigParser();
DefaultFontConfig fontInfoConfig = parser.parse(cfg, strict);
DefaultFontConfigurator fontInfoConfigurator
- = new DefaultFontConfigurator(fontManager, listener, strict);
+ = new DefaultFontConfigurator(fontManager, null, strict);
List<EmbedFontInfo> fontInfoList = fontInfoConfigurator.configure(fontInfoConfig);
fontManager.saveCache();
FontSetup.setup(fontInfo, fontInfoList, resourceResolver, useComplexScriptFeatures);
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 027c35037..8e0d0bca9 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -78,6 +78,7 @@ public class TestConverter {
public static void main(String[] args) {
if (args == null || args.length == 0) {
System.out.println("test suite file name required");
+ return;
}
TestConverter tc = new TestConverter();
@@ -284,8 +285,8 @@ public class TestConverter {
FopFactory fopFactory = FopFactory.newInstance(baseUri);
FOUserAgent userAgent = fopFactory.newFOUserAgent();
- userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
- userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
+ userAgent.getRendererOptions().put("fineDetail", Boolean.valueOf(false));
+ userAgent.getRendererOptions().put("consistentOutput", Boolean.valueOf(true));
userAgent.setProducer("Testsuite Converter");
String outname = res;
@@ -311,7 +312,7 @@ public class TestConverter {
File f1 = new File(destdir, outname + ".at.xml");
File f2 = new File(compare, outname + ".at.xml");
if (!compareFiles(f1, f2)) {
- differ.put(outname + ".at.xml", new Boolean(pass));
+ differ.put(outname + ".at.xml", Boolean.valueOf(pass));
}
}
} catch (Exception e) {
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index 8ca048da3..8460e5964 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -26,7 +26,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.List;
-import java.util.Vector;
import org.xml.sax.SAXException;
@@ -678,8 +677,7 @@ class FOPTaskStarter {
private void render(File xmlFile, File xsltFile, File outFile, String outputFormat) {
//TODO: implement support for XSLT params
- final Vector xsltParams = null;
- InputHandler inputHandler = new InputHandler(xmlFile, xsltFile, xsltParams);
+ InputHandler inputHandler = new InputHandler(xmlFile, xsltFile, null);
try {
renderInputHandler(inputHandler, outFile, outputFormat);
} catch (Exception ex) {