From: Glenn Adams Date: Thu, 7 Aug 2014 20:27:59 +0000 (+0000) Subject: Fix or suppress 3-instance findbug warnings. X-Git-Tag: fop-2_0~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9feb56844650da39b4df4a161ce268a68f8c7ca6;p=xmlgraphics-fop.git Fix or suppress 3-instance findbug warnings. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1616590 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml index 791f22ec8..c11fdc732 100644 --- a/findbugs-exclude.xml +++ b/findbugs-exclude.xml @@ -25,10 +25,6 @@ - - - - @@ -70,22 +66,10 @@ - - - - - - - - - - - - @@ -116,8 +100,12 @@ - + + + + + @@ -131,10 +119,6 @@ - - - - @@ -147,10 +131,6 @@ - - - - @@ -176,8 +156,13 @@ - + + + + + + @@ -199,10 +184,6 @@ - - - - @@ -211,10 +192,6 @@ - - - - diff --git a/src/java/org/apache/fop/afp/AFPResourceInfo.java b/src/java/org/apache/fop/afp/AFPResourceInfo.java index 7cad51596..d668a82af 100644 --- a/src/java/org/apache/fop/afp/AFPResourceInfo.java +++ b/src/java/org/apache/fop/afp/AFPResourceInfo.java @@ -158,11 +158,10 @@ public class AFPResourceInfo { } AFPResourceInfo ri = (AFPResourceInfo)obj; - return (uri == ri.uri || uri != null && uri.equals(ri.uri)) - && (imageDimension == ri.imageDimension - || (imageDimension != null && imageDimension.equals(ri.imageDimension))) - && (name == ri.name || name != null && name.equals(ri.name)) - && (level == ri.level || level != null && level.equals(ri.level)); + return (uri != null && uri.equals(ri.uri)) + && (imageDimension != null && imageDimension.equals(ri.imageDimension)) + && (name != null && name.equals(ri.name)) + && (level != null && level.equals(ri.level)); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/apps/MimeConstants.java b/src/java/org/apache/fop/apps/MimeConstants.java index 75b05c8b7..33030e22f 100644 --- a/src/java/org/apache/fop/apps/MimeConstants.java +++ b/src/java/org/apache/fop/apps/MimeConstants.java @@ -22,6 +22,7 @@ package org.apache.fop.apps; /** * Frequently used MIME types for various file formats used when working with Apache FOP. */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE") public interface MimeConstants extends org.apache.xmlgraphics.util.MimeConstants { /** Apache FOP's AWT preview (non-standard MIME type) */ diff --git a/src/java/org/apache/fop/cli/ImageInputHandler.java b/src/java/org/apache/fop/cli/ImageInputHandler.java index b8439bc7a..71c5b0073 100644 --- a/src/java/org/apache/fop/cli/ImageInputHandler.java +++ b/src/java/org/apache/fop/cli/ImageInputHandler.java @@ -52,7 +52,7 @@ public class ImageInputHandler extends InputHandler { protected Source createXSLTSource() { Source src = super.createXSLTSource(); if (src == null) { - src = new StreamSource(getClass().getResource("image2fo.xsl").toExternalForm()); + src = new StreamSource(ImageInputHandler.class.getResource("image2fo.xsl").toExternalForm()); } return src; } diff --git a/src/java/org/apache/fop/events/EventListener.java b/src/java/org/apache/fop/events/EventListener.java index 4889d3299..fa1bb5beb 100644 --- a/src/java/org/apache/fop/events/EventListener.java +++ b/src/java/org/apache/fop/events/EventListener.java @@ -22,6 +22,7 @@ package org.apache.fop.events; /** * This interface is implemented by clients who want to listen for events. */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE") public interface EventListener extends java.util.EventListener { /** diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 9089304df..937fc62e3 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -343,7 +343,7 @@ public final class FOPropertyMapping implements Constants { addSubpropMakerName("precedence", CP_PRECEDENCE); } - // SuppressFBWarnings("MS_EXPOSE_REP") + // @SuppressFBWarnings("MS_EXPOSE_REP") return generics; } diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index 5d525ee8c..8abf3d992 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -420,18 +420,14 @@ public class Marker extends FObjMixed { if (o instanceof MarkerAttribute) { MarkerAttribute attr = (MarkerAttribute) o; - return ((attr.namespace == this.namespace) - || (attr.namespace != null - && attr.namespace.equals(this.namespace))) - && ((attr.qname == this.qname) - || (attr.qname != null - && attr.qname.equals(this.qname))) - && ((attr.name == this.name) - || (attr.name != null - && attr.name.equals(this.name))) - && ((attr.value == this.value) - || (attr.value != null - && attr.value.equals(this.value))); + return (attr.namespace != null + && attr.namespace.equals(this.namespace)) + && (attr.qname != null + && attr.qname.equals(this.qname)) + && (attr.name != null + && attr.name.equals(this.name)) + && (attr.value != null + && attr.value.equals(this.value)); } else { return false; } diff --git a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java index 6c820eeab..95ed0de85 100644 --- a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java +++ b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java @@ -78,7 +78,7 @@ public class ToBeImplementedProperty extends Property { * Since a PropertyCache is not used here, returning true helps the PropertyCache when a non * implemented property is part of an implemented one. */ - // FBOFF: EQ_ALWAYS_TRUE + // @SuppressFBWarnings("EQ_ALWAYS_TRUE") return true; } } diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 0c94b256f..cea7e5107 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -245,13 +245,13 @@ public class FontInfo { // only if the font may be substituted // fallback 1: try the same font-family and weight with default style - if (internalFontKey == null && style != Font.STYLE_NORMAL) { + if (internalFontKey == null && !style.equals(Font.STYLE_NORMAL)) { key = createFontKey(family, Font.STYLE_NORMAL, weight); internalFontKey = getInternalFontKey(key); } // fallback 2: try the same font-family with default style and try to adjust weight - if (internalFontKey == null && style != Font.STYLE_NORMAL) { + if (internalFontKey == null && !style.equals(Font.STYLE_NORMAL)) { key = findAdjustWeight(family, Font.STYLE_NORMAL, weight); if (key != null) { internalFontKey = getInternalFontKey(key); diff --git a/src/java/org/apache/fop/hyphenation/PatternParser.java b/src/java/org/apache/fop/hyphenation/PatternParser.java index 7961b28d9..2fc5984ad 100644 --- a/src/java/org/apache/fop/hyphenation/PatternParser.java +++ b/src/java/org/apache/fop/hyphenation/PatternParser.java @@ -261,7 +261,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { parser = createParser(); parser.setContentHandler(this); parser.setErrorHandler(this); - InputStream stream = this.getClass().getResourceAsStream("classes.xml"); + InputStream stream = PatternParser.class.getResourceAsStream("classes.xml"); InputSource source = new InputSource(stream); try { parser.parse(source); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index c58febd0e..0906e9faa 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -419,7 +419,9 @@ public class TableStepper { for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); if (activeCell.endsOnRow(activeRowIndex)) { - rowFinished &= activeCell.finishes(step); + if (!activeCell.finishes(step)) { + rowFinished = false; + } } } if (rowFinished) { diff --git a/src/java/org/apache/fop/render/Graphics2DImagePainter.java b/src/java/org/apache/fop/render/Graphics2DImagePainter.java index 6b4754720..e72fc1e46 100644 --- a/src/java/org/apache/fop/render/Graphics2DImagePainter.java +++ b/src/java/org/apache/fop/render/Graphics2DImagePainter.java @@ -24,6 +24,7 @@ package org.apache.fop.render; * a Graphics2D instance can implement this interface to paint themselves. * @deprecated use {@link org.apache.xmlgraphics.java2d.Graphics2DImagePainter} directly! */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE") public interface Graphics2DImagePainter extends org.apache.xmlgraphics.java2d.Graphics2DImagePainter { diff --git a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java index 0067f8367..30b3af9dd 100644 --- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java @@ -62,6 +62,15 @@ public class ImageProxyPanel extends JPanel { public ImageProxyPanel(AWTRenderer renderer, int page) { this.renderer = renderer; this.page = page; + try { + Dimension size = renderer.getPageImageSize(page); + Insets insets = getInsets(); + size.width += insets.left + insets.right; + size.height += insets.top + insets.bottom; + this.size = size; + } catch (Exception e) { + this.size = new Dimension(10, 10); + } // Allows single panel to appear behind page display. // Important for textured L&Fs. setOpaque(false); @@ -78,17 +87,6 @@ public class ImageProxyPanel extends JPanel { * @return the size of the page plus the border. */ public Dimension getPreferredSize() { - if (size == null) { - try { - Insets insets = getInsets(); - size = renderer.getPageImageSize(page); - size = new Dimension(size.width + insets.left + insets.right, - size.height + insets.top + insets.bottom); - } catch (FOPException fopEx) { - // Arbitary size. Doesn't really matter what's returned here. - return new Dimension(10, 10); - } - } return size; } @@ -96,7 +94,7 @@ public class ImageProxyPanel extends JPanel { * Sets the number of the page to be displayed and refreshes the display. * @param pg the page number */ - public void setPage(int pg) { + public synchronized void setPage(int pg) { if (page != pg) { page = pg; imageRef = null; diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java index 53cd585c9..643c78b7c 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java @@ -64,7 +64,7 @@ public class PreviewDialogAboutBox extends Dialog implements ActionListener { JPanel insetsPanel3 = new JPanel(); okButton = new JButton(); JLabel imageControl1 = new JLabel(); - imageControl1.setIcon(new ImageIcon(getClass().getResource("images/fop.gif"))); + imageControl1.setIcon(new ImageIcon(PreviewDialogAboutBox.class.getResource("images/fop.gif"))); JLabel label1 = new JLabel(translator.getString("About.Product")); JLabel label2 = new JLabel(translator.getString("About.Version") + " " + Version.getVersion()); diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java index 36ded2f7f..93cc29e4f 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -320,7 +320,7 @@ public class PreviewPanel extends JPanel { // ***** MouseListener ***** - public void mousePressed(MouseEvent e) { + public synchronized void mousePressed(MouseEvent e) { startPosX = e.getX(); startPosY = e.getY(); } @@ -357,6 +357,7 @@ public class PreviewPanel extends JPanel { // This page intentionally left blank // Makes 0th/1st page on rhs gridPanel.add(new JLabel("")); + // @SuppressFBWarnings("SF_SWITCH_FALLTHROUGH") case CONTINUOUS: currentPage = 0; firstPage = 0; diff --git a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java index e97c68bd1..16471fe9c 100644 --- a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java @@ -56,8 +56,8 @@ public class IFGraphicContext extends GraphicContext { /** * {@inheritDoc} */ + // @SuppressFBWarnings("CN_IDIOM_NO_SUPER_CALL") public Object clone() { - // FBOFF: CN_IDIOM_NO_SUPER_CALL return new IFGraphicContext(this); } diff --git a/src/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java b/src/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java index 588d417fa..c3bf523d3 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java @@ -261,11 +261,13 @@ class Java2DGraphicsPainter implements GraphicsPainter { closePath(); getG2D().fill(currentPath); currentPath = null; + break; case Constants.EN_NONE: // No rule is drawn break; default: + break; } // end switch restoreGraphicsState(); } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index ec837c65c..75957c396 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -893,11 +893,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem closePath(); state.getGraph().fill(currentPath); currentPath = null; + break; case EN_NONE: // No rule is drawn break; default: + break; } // end switch super.renderLeader(area); diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java index 7b3878627..05045b7e7 100644 --- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java +++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java @@ -715,6 +715,7 @@ public class PCLGenerator { boolean monochrome = isMonochromeImage(img); if (!monochrome) { //Transparency mask disabled. Doesn't work reliably + /* final boolean transparencyDisabled = true; RenderedImage mask = (transparencyDisabled ? null : getMask(img, effDim)); if (mask != null) { @@ -724,11 +725,12 @@ public class PCLGenerator { paintMonochromeBitmap(mask, effResolution); popCursorPos(); } + */ RenderedImage red = BitmapImageUtil.convertToMonochrome( img, effDim, this.ditheringQuality); selectCurrentPattern(0, 0); //Solid black - setTransparencyMode(sourceTransparency || mask != null, true); + setTransparencyMode(sourceTransparency /*|| mask != null*/, true); paintMonochromeBitmap(red, effResolution); } else { RenderedImage effImg = img; diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java index a71fe9417..13d61dc35 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java @@ -101,7 +101,6 @@ public class PDFImageHandlerSVG implements ImageHandler { GraphicsNode root; try { root = builder.build(ctx, clonedDoc); - builder = null; } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( context.getUserAgent().getEventBroadcaster()); diff --git a/src/java/org/apache/fop/render/ps/NativeTextHandler.java b/src/java/org/apache/fop/render/ps/NativeTextHandler.java index b9784d69c..d487d3279 100644 --- a/src/java/org/apache/fop/render/ps/NativeTextHandler.java +++ b/src/java/org/apache/fop/render/ps/NativeTextHandler.java @@ -147,7 +147,7 @@ public class NativeTextHandler implements PSTextHandler { final int l = text.length(); for (int i = 0; i < l; i++) { final char ch = text.charAt(i); - final char mch = this.font.mapChar(ch); + final char mch = font.mapChar(ch); PSGenerator.escapeChar(mch, target); } } @@ -157,13 +157,13 @@ public class NativeTextHandler implements PSTextHandler { } private void establishCurrentFont() throws IOException { - if ((currentFontName != this.font.getFontName()) - || (currentFontSize != this.font.getFontSize())) { + if (!currentFontName.equals(font.getFontName()) + || (currentFontSize != font.getFontSize())) { PSGenerator gen = getPSGenerator(); - gen.writeln("/" + this.font.getFontTriplet().getName() + " " + gen.writeln("/" + font.getFontTriplet().getName() + " " + gen.formatDouble(font.getFontSize() / 1000f) + " F"); - currentFontName = this.font.getFontName(); - currentFontSize = this.font.getFontSize(); + currentFontName = font.getFontName(); + currentFontSize = font.getFontSize(); } } diff --git a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java index be479ec31..6d277f2f0 100644 --- a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java +++ b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java @@ -138,8 +138,6 @@ public class PSImageHandlerSVG implements ImageHandler { float sx = pos.width / w; float sy = pos.height / h; - ctx = null; - gen.commentln("%FOPBeginSVG"); gen.saveGraphicsState(); final boolean clip = false; diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index d6c47d84c..5e3fa1ca5 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -278,8 +278,6 @@ public class PSSVGHandler extends AbstractGenericSVGHandler float sx = psInfo.getWidth() / w; float sy = psInfo.getHeight() / h; - ctx = null; - try { gen.commentln("%FOPBeginSVG"); gen.saveGraphicsState(); diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index eeb1aff06..d9892ad83 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -1101,7 +1101,7 @@ public class RTFHandler extends FOEventHandler { } catch (ImageException ie) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); - eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null); + eventProducer.imageError(this, uri, ie, null); } catch (FileNotFoundException fe) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java index 617ad2abc..4dfcd5bec 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java @@ -37,8 +37,6 @@ import java.io.Writer; public class RtfPageArea extends RtfContainer { private RtfPage currentPage; - private RtfNull nullChild; - private RtfAttributes childAttributes; /** Create an RTF element as a child of given container */ RtfPageArea(RtfFile f, Writer w) throws IOException { diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index b0391e7cc..5a1615541 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -331,8 +331,8 @@ public class RtfTextrun extends RtfContainer { * @throws IOException for I/O problems */ public void addBookmark(String id) throws IOException { - if (id != "") { - // if id is not empty, add boormark + if (id.length() > 0) { + // if id is not empty, add bookmark new RtfBookmark(this, writer, id); } } diff --git a/src/java/org/apache/fop/tools/anttasks/FileCompare.java b/src/java/org/apache/fop/tools/anttasks/FileCompare.java index 8591babe2..2c307869e 100644 --- a/src/java/org/apache/fop/tools/anttasks/FileCompare.java +++ b/src/java/org/apache/fop/tools/anttasks/FileCompare.java @@ -42,14 +42,13 @@ public class FileCompare { private String referenceDirectory; private String testDirectory; private String[] filenameList; - private String filenames; /** * Sets directory for test files. * @param testDirectory the test directory */ public void setTestDirectory(String testDirectory) { - if (!(testDirectory.endsWith("/") | testDirectory.endsWith("\\"))) { + if (!(testDirectory.endsWith("/") || testDirectory.endsWith("\\"))) { testDirectory += File.separator; } this.testDirectory = testDirectory; @@ -61,7 +60,7 @@ public class FileCompare { */ public void setReferenceDirectory(String referenceDirectory) { if (!(referenceDirectory.endsWith("/") - | referenceDirectory.endsWith("\\"))) { + || referenceDirectory.endsWith("\\"))) { referenceDirectory += File.separator; } this.referenceDirectory = referenceDirectory; diff --git a/src/java/org/apache/fop/tools/fontlist/FontListSerializer.java b/src/java/org/apache/fop/tools/fontlist/FontListSerializer.java index eab3caa56..3b3d13245 100644 --- a/src/java/org/apache/fop/tools/fontlist/FontListSerializer.java +++ b/src/java/org/apache/fop/tools/fontlist/FontListSerializer.java @@ -81,7 +81,7 @@ public class FontListSerializer { while (iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); String familyName = (String)entry.getKey(); - if (singleFamily != null && familyName != singleFamily) { + if (singleFamily != null && !singleFamily.equals(familyName)) { continue; } atts.clear();