]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix 2-instance findbug warnings.
authorGlenn Adams <gadams@apache.org>
Thu, 7 Aug 2014 06:46:57 +0000 (06:46 +0000)
committerGlenn Adams <gadams@apache.org>
Thu, 7 Aug 2014 06:46:57 +0000 (06:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1616416 13f79535-47bb-0310-9956-ffa450edef68

28 files changed:
findbugs-exclude.xml
src/java/org/apache/fop/afp/AFPPaintingState.java
src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
src/java/org/apache/fop/cli/Main.java
src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
src/java/org/apache/fop/fo/pagination/PageProductionException.java
src/java/org/apache/fop/fo/pagination/PageSequence.java
src/java/org/apache/fop/fo/properties/CharacterProperty.java
src/java/org/apache/fop/fo/properties/GenericShorthandParser.java
src/java/org/apache/fop/fonts/Glyphs.java
src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
src/java/org/apache/fop/fonts/truetype/OpenFont.java
src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
src/java/org/apache/fop/render/ps/PSImageFormResource.java
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
src/java/org/apache/fop/servlet/FopServlet.java
src/java/org/apache/fop/tools/TestConverter.java
src/java/org/apache/fop/tools/anttasks/RunTest.java
src/java/org/apache/fop/util/AbstractPaintingState.java
src/java/org/apache/fop/util/ColorWithFallback.java

index 4af7948ad10b92cfcb08ace10982782fd6cffb1e..791f22ec8c6f7534c95db68ba0d7fcdf5edb1e2a 100644 (file)
     <!-- 4 warnings -->
     <Bug pattern="DM_BOOLEAN_CTOR"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="DM_BOXED_PRIMITIVE_TOSTRING"/>
-  </Match>
   <Match>
     <!-- 29 warnings -->
     <Bug pattern="DM_CONVERT_CASE"/>
     <!-- 88 warnings -->
     <Bug pattern="DM_NUMBER_CTOR"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="DM_STRING_TOSTRING"/>
-  </Match>
   <Match>
     <!-- 4 warnings -->
     <Bug pattern="DM_STRING_VOID_CTOR"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="DMI_INVOKING_TOSTRING_ON_ARRAY"/>
-  </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/>
-  </Match>
   <Match>
     <!-- 84 warnings -->
     <Bug pattern="EI_EXPOSE_REP"/>
       </And>
     </Or>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
-  </Match>
   <Match>
     <!-- 3 warnings -->
     <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ"/>
     <!-- 12 warnings -->
     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="IM_BAD_CHECK_FOR_ODD"/>
-  </Match>
   <Match>
     <!-- 3 warnings -->
     <Bug pattern="IS2_INCONSISTENT_SYNC"/>
     <!-- 9 warnings -->
     <Bug pattern="LI_LAZY_INIT_STATIC"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="MF_CLASS_MASKS_FIELD"/>
-  </Match>
   <Match>
     <Bug pattern="MS_EXPOSE_REP"/>
     <Or>
     <!-- 4 warnings -->
     <Bug pattern="NP_NULL_ON_SOME_PATH"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
-  </Match>
   <Match>
     <!-- 3 warnings -->
     <Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT"/>
     <!-- 4 warnings -->
     <Bug pattern="OS_OPEN_STREAM"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
-  </Match>
   <Match>
     <!-- 46 warnings -->
     <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
     <!-- 11 warnings -->
     <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION"/>
-  </Match>
   <Match>
     <!-- 33 warnings -->
     <Bug pattern="SE_BAD_FIELD"/>
   </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
-  </Match>
-  <Match>
-    <!-- 2 warnings -->
-    <Bug pattern="SE_BAD_FIELD_STORE"/>
-  </Match>
   <Match>
     <!-- 6 warnings -->
     <Bug pattern="SE_INNER_CLASS"/>
index 74506aa7ea5a11a06756b9e04041a66777ecf061..5a606dfdf28efcc96c01d65f0d4db6c16efcae09 100644 (file)
@@ -57,7 +57,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
     private float bitmapEncodingQuality;
 
     /** color image handler */
-    private ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
+    private transient ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
 
     /**
      * true if certain image formats may be embedded unchanged in their native
index 01333f367add149b2bc8175beb399de3016555ee..d9836f682b2ebefc1c93e9cd1e080c60a43410c8 100644 (file)
@@ -130,13 +130,17 @@ public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder
 
     /** {@inheritDoc} */
     public String toString() {
-        String coordsStr = "";
+        StringBuffer sb = new StringBuffer();
         for (int i = 0; i < coords.length; i++) {
-            coordsStr += (i % 2 == 0) ? "x" : "y";
-            coordsStr += (i / 2) + "=" + coords[i] + ",";
+            if (sb.length() > 0) {
+                sb.append(',');
+            }
+            sb.append((i % 2 == 0) ? 'x' : 'y');
+            sb.append(i / 2);
+            sb.append('=');
+            sb.append(coords[i]);
         }
-        coordsStr = coordsStr.substring(0, coordsStr.length() - 1);
-        return getName() + "{" + coordsStr + "}";
+        return getName() + "{" + sb.toString() + "}";
     }
 
     /**
index 6ae81ea21b8518a4951fc0c1230955cb9e1677ad..648313efd6c6d0f7e9b032e8036a64cf44285c86 100644 (file)
@@ -25,6 +25,8 @@ import java.io.OutputStream;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
@@ -125,10 +127,15 @@ public final class Main {
      */
     public static void startFOPWithDynamicClasspath(String[] args) {
         try {
-            URL[] urls = getJARList();
+            final URL[] urls = getJARList();
             //System.out.println("CCL: "
             //    + Thread.currentThread().getContextClassLoader().toString());
-            ClassLoader loader = new java.net.URLClassLoader(urls, null);
+            ClassLoader loader = (ClassLoader)
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        return new java.net.URLClassLoader(urls, null);
+                    }
+                });
             Thread.currentThread().setContextClassLoader(loader);
             Class clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
             //System.out.println("CL: " + clazz.getClassLoader().toString());
index 99855b8159cc86b226f38627f7f9e711134b5f6d..49a67a154d8e927c3cd195a1cf3d5a6df3910a71 100644 (file)
@@ -104,7 +104,7 @@ public abstract class AbstractPageSequence extends FObj implements CommonAccessi
                     startingPageNumber++;
                 }
             } else if (pageNumberType == EN_AUTO_EVEN) {
-                if (startingPageNumber % 2 == 1) {
+                if (startingPageNumber % 2 != 0) {
                     startingPageNumber++;
                 }
             }
index c64bdada3a74252b4b6c1a4a0fae510522f24bf5..c0f14b0ea1d23f5c476d3b2c7b5bddf2fbb1dbc5 100644 (file)
@@ -36,7 +36,7 @@ public class PageProductionException extends RuntimeException {
     private static final long serialVersionUID = -5126033718398975158L;
 
     private String localizedMessage;
-    private Locator locator;
+    private transient Locator locator;
 
 
     /**
index 39a19b6222d119f32a7939e44975234384b3b971..d17abf6230b900ee3397b39d1fd18f158a6c6b50 100644 (file)
@@ -271,7 +271,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra
         if (pageSequenceMaster == null) {
             return simplePageMaster;
         }
-        boolean isOddPage = ((page % 2) == 1);
+        boolean isOddPage = ((page % 2) != 0);
         if (log.isDebugEnabled()) {
             log.debug("getNextSimplePageMaster(page=" + page
                     + " isOdd=" + isOddPage
index 3c2f56d50ce81e37aad43bab06e04abf4d97bf98..c5aa2f939a85c1050536d3ee7ceb74544c39cb43 100644 (file)
@@ -90,7 +90,7 @@ public final class CharacterProperty extends Property {
      * @return this.character cast as a String
      */
     public String getString() {
-        return new Character(character).toString();
+        return Character.toString(character);
     }
 
     @Override
index 140b96aac8092c47492c6bf64f419b3b096976ff..42b65486c0a0e05a7261cd4d8b881f13777a3b4a 100644 (file)
@@ -83,17 +83,20 @@ public class GenericShorthandParser implements ShorthandParser {
                                                PropertyList propertyList)
                     throws PropertyException {
         Property prop = null;
-        String vProperty = "";
+        StringBuffer vProperty = new StringBuffer();
         // Try each of the stored values in turn
         Iterator iprop = property.getList().iterator();
         while (iprop.hasNext() && prop == null) {
             Property p = (Property)iprop.next();
             if (p.getNCname() != null) {
-                vProperty += p.getNCname() + " ";
+                if (vProperty.length() > 0) {
+                    vProperty.append(' ');
+                }
+                vProperty.append(p.getNCname());
             }
             prop = maker.convertShorthandProperty(propertyList, p, null);
         }
-        propertyList.validatePropertyValue(vProperty.trim(), prop, property);
+        propertyList.validatePropertyValue(vProperty.toString(), prop, property);
         return prop;
     }
 
index dfc44675b735d48730f5dbbf2b52eb7265bfd1ae..04098f5909531d7e2dd918eb0d73c1d711b6dbe6 100644 (file)
@@ -1277,7 +1277,7 @@ public final class Glyphs {
      * @return the name of the glyph
      */
     public static String charToGlyphName(char ch) {
-        return stringToGlyph(new Character(ch).toString());
+        return stringToGlyph(Character.toString(ch));
     }
 
     /**
index a9c471d5e4ff94ad35a49ccf5e327865067b91e5..d9c6f3b3a38ba0cd36845ea0d4a57ebb4e4e34c1 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.fop.fonts.truetype;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
 
 
 /**
@@ -57,19 +58,17 @@ public class OFDirTabEntry {
 
         offset = in.readTTFULong();
         length = in.readTTFULong();
-        String tagStr = new String(tag, "ISO-8859-1");
 
-        return tagStr;
+        return getTagString();
     }
 
 
     @Override
     public String toString() {
-        return "Read dir tab ["
-            + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"
+        return "Read dir tab [" + Arrays.toString(tag) + "]"
             + " offset: " + offset
             + " length: " + length
-            + " name: " + tag;
+            + " name: " + getTagString();
     }
 
     /**
index fc2acf8cad2b3f6a3384ba926fe7442cebd89b06..b0288b9980042f4e0580385127158b8a782de332 100644 (file)
@@ -266,7 +266,7 @@ public abstract class OpenFont {
     /**
      * Key-value helper class.
      */
-    final static class UnicodeMapping implements Comparable {
+    static final class UnicodeMapping implements Comparable {
 
         private final int unicodeIndex;
         private final int glyphIndex;
index 941dc2b5db41d7d87f648cc42e0259209e373307..834a72ee817683d37958d4b52fc2621e1f93b86c 100644 (file)
@@ -91,7 +91,7 @@ public abstract class AbstractBreaker {
      * Helper class, extending the functionality of the
      * basic {@link BlockKnuthSequence}.
      */
-    public class BlockSequence extends BlockKnuthSequence {
+    public static class BlockSequence extends BlockKnuthSequence {
 
         private static final long serialVersionUID = -5348831120146774118L;
 
index cad6fd3cf3937326fab7ba6405e3832b9a4ed07f..ee4143982dd4fc2c355b5985d88ddb7b6b9fc3c4 100644 (file)
@@ -38,7 +38,8 @@ import org.apache.fop.traits.MinOptMax;
 public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLayoutManager {
 
     /** The page number citation object */
-    protected AbstractPageNumberCitation fobj;
+    protected AbstractPageNumberCitation citation;
+
     /** Font for the page-number-citation */
     protected Font font;
 
@@ -55,15 +56,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
      */
     public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) {
         super(node);
-        fobj = node;
+        citation = node;
     }
 
     /** {@inheritDoc} */
     public void initialize() {
-        FontInfo fi = fobj.getFOEventHandler().getFontInfo();
-        FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
-        font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
-        setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
+        FontInfo fi = citation.getFOEventHandler().getFontInfo();
+        FontTriplet[] fontkeys = citation.getCommonFont().getFontState(fi);
+        font = fi.getFontInstance(fontkeys[0], citation.getCommonFont().fontSize.getValue(this));
+        setCommonBorderPaddingBackground(citation.getCommonBorderPaddingBackground());
     }
 
     /**
@@ -72,11 +73,11 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
     protected AlignmentContext makeAlignmentContext(LayoutContext context) {
         return new AlignmentContext(
                 font
-                , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
-                , fobj.getAlignmentAdjust()
-                , fobj.getAlignmentBaseline()
-                , fobj.getBaselineShift()
-                , fobj.getDominantBaseline()
+                , citation.getLineHeight().getOptimum(this).getLength().getValue(this)
+                , citation.getAlignmentAdjust()
+                , citation.getAlignmentBaseline()
+                , citation.getBaselineShift()
+                , citation.getDominantBaseline()
                 , context.getAlignmentContext()
             );
     }
@@ -114,7 +115,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
     protected InlineArea getEffectiveArea(LayoutContext layoutContext) {
         InlineArea area = getPageNumberCitationArea();
         if (!layoutContext.treatAsArtifact()) {
-            TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
+            TraitSetter.addStructureTreeElement(area, citation.getStructureTreeElement());
         }
         return area;
     }
@@ -125,9 +126,9 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
             text = new TextArea();
             text.addWord(citationString, 0);
         } else {
-            UnresolvedPageNumber unresolved = new UnresolvedPageNumber(fobj.getRefId(), font,
+            UnresolvedPageNumber unresolved = new UnresolvedPageNumber(citation.getRefId(), font,
                     getReferenceType());
-            getPSLM().addUnresolvedArea(fobj.getRefId(), unresolved);
+            getPSLM().addUnresolvedArea(citation.getRefId(), unresolved);
             text = unresolved;
         }
         setTraits(text);
@@ -141,7 +142,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
     protected abstract boolean getReferenceType();
 
     private void setTraits(TextArea text) {
-        TraitSetter.setProducerID(text, fobj.getId());
+        TraitSetter.setProducerID(text, citation.getId());
         int bidiLevel = getBidiLevel();
         text.setBidiLevel(bidiLevel);
         int width = getStringWidth(citationString); // TODO: [GA] !I18N!
@@ -149,15 +150,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
         text.setBPD(font.getAscender() - font.getDescender());
         text.setBaselineOffset(font.getAscender());
         TraitSetter.addFontTraits(text, font);
-        text.addTrait(Trait.COLOR, fobj.getColor());
-        TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
+        text.addTrait(Trait.COLOR, citation.getColor());
+        TraitSetter.addTextDecoration(text, citation.getTextDecoration());
     }
 
     /**
      * @return bidi level governing abstract page number citation
      */
     protected int getBidiLevel() {
-        return fobj.getBidiLevel();
+        return citation.getBidiLevel();
     }
 
 }
index aa8815ffc5a2b1979655b06956ee08720cb5f0c6..d8ebc6dbf92397468ce4dbb31c24f772d72bb436 100644 (file)
@@ -191,7 +191,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
     }
 
     // this class represents a paragraph
-    private class Paragraph extends InlineKnuthSequence {
+    private static class Paragraph extends InlineKnuthSequence {
 
         private static final long serialVersionUID = 5862072380375189105L;
 
@@ -239,7 +239,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
 
             // add the element representing text indentation
             // at the beginning of the first paragraph
-            if (isFirstInBlock && knuthParagraphs.size() == 0
+            if (layoutManager.isFirstInBlock && layoutManager.knuthParagraphs.size() == 0
                         && textIndent != 0) {
                 this.add(new KnuthInlineBox(textIndent, null,
                                       null, false));
@@ -250,7 +250,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         public void endParagraph() {
             KnuthSequence finishedPar = this.endSequence();
             if (finishedPar != null) {
-                knuthParagraphs.add(finishedPar);
+                layoutManager.knuthParagraphs.add(finishedPar);
             }
         }
 
index 81846615f77e1f4a44842d43c7d4a30785ee2b64..c082bc41fa3d636560b410bc1b7ba7d7a2e71f14 100644 (file)
@@ -40,8 +40,8 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat
 
     @Override
     protected PageViewport getCitedPage() {
-        if (getPSLM().associateLayoutManagerID(fobj.getRefId())) {
-            return getPSLM().getLastPVWithID(fobj.getRefId());
+        if (getPSLM().associateLayoutManagerID(citation.getRefId())) {
+            return getPSLM().getLastPVWithID(citation.getRefId());
         } else {
             return null;
         }
index a4976f8330245e75c72f5e30ecdf2a56ad09399b..556c2f575312f40978f6b781f1dc93f475ba43ec 100644 (file)
@@ -40,7 +40,7 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL
 
     @Override
     protected PageViewport getCitedPage() {
-        return getPSLM().getFirstPVWithID(fobj.getRefId());
+        return getPSLM().getFirstPVWithID(citation.getRefId());
     }
 
     @Override
index 0926b4e75069acabdc6fa0a4fa7209881adf0534..560c408c2b6365bf07845aae299ff240170f3c10 100644 (file)
@@ -61,7 +61,7 @@ public class PDFJavaScriptLaunchAction extends PDFAction {
 
         PDFJavaScriptLaunchAction launch = (PDFJavaScriptLaunchAction) obj;
 
-        if (!launch.script.toString().equals(script.toString())) {
+        if (!launch.script.equals(script)) {
             return false;
         }
 
index d0d35e84ba8c1acc2fd15bfbac871585c0bebc0f..0067f8367e0111010383f3729cd3ac7444a8f628 100644 (file)
@@ -128,10 +128,11 @@ public class ImageProxyPanel extends JPanel {
                 image = (BufferedImage)imageRef.get();
             }
 
-            int x = (getWidth() - image.getWidth()) / 2;
-            int y = (getHeight() - image.getHeight()) / 2;
-
-            graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+            if (image != null) {
+                int x = (getWidth() - image.getWidth()) / 2;
+                int y = (getHeight() - image.getHeight()) / 2;
+                graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+            }
         } catch (FOPException fopEx) {
             fopEx.printStackTrace();
         }
index dc9256389e6bb9bd56edec9937bee49c489429bf..a0a7ddd01237ee70b92fd3e73e537f51bfb63727 100644 (file)
@@ -626,7 +626,7 @@ public class PreviewDialog extends JFrame implements StatusListener {
         }
 
         public void run() {
-            processStatus.setText(message.toString());
+            processStatus.setText(message);
         }
     }
 
index 9742036b79b9161d27b729a6e794a89af08ddccb..5f69fbadbb4656ba0ca9358d83370ba51f91380e 100644 (file)
@@ -116,52 +116,59 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
             // TODO: Implement code to combine image with background color if transparency is not allowed\r
             // here we need to inflate the PNG pixel data, which includes alpha, separate the alpha channel\r
             // and then deflate it back again\r
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-            DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());\r
-            InputStream in = ((ImageRawStream) image).createInputStream();\r
+            ByteArrayOutputStream baos = null;\r
+            DeflaterOutputStream dos = null;\r
+            InputStream in = null;\r
             try {\r
-                InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
-                DataInputStream dataStream = new DataInputStream(infStream);\r
-                // offset is the byte offset of the alpha component\r
-                int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA\r
-                int numColumns = image.getSize().getWidthPx();\r
-                int bytesPerRow = numberOfInterleavedComponents * numColumns;\r
-                int filter;\r
-                // read line by line; the first byte holds the filter\r
-                while ((filter = dataStream.read()) != -1) {\r
-                    byte[] bytes = new byte[bytesPerRow];\r
-                    dataStream.readFully(bytes, 0, bytesPerRow);\r
-                    dos.write((byte) filter);\r
-                    for (int j = 0; j < numColumns; j++) {\r
-                        dos.write(bytes, offset, 1);\r
-                        offset += numberOfInterleavedComponents;\r
+                baos = new ByteArrayOutputStream();\r
+                dos = new DeflaterOutputStream(baos, new Deflater());\r
+                in = ((ImageRawStream) image).createInputStream();\r
+                try {\r
+                    InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
+                    DataInputStream dataStream = new DataInputStream(infStream);\r
+                    // offset is the byte offset of the alpha component\r
+                    int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA\r
+                    int numColumns = image.getSize().getWidthPx();\r
+                    int bytesPerRow = numberOfInterleavedComponents * numColumns;\r
+                    int filter;\r
+                    // read line by line; the first byte holds the filter\r
+                    while ((filter = dataStream.read()) != -1) {\r
+                        byte[] bytes = new byte[bytesPerRow];\r
+                        dataStream.readFully(bytes, 0, bytesPerRow);\r
+                        dos.write((byte) filter);\r
+                        for (int j = 0; j < numColumns; j++) {\r
+                            dos.write(bytes, offset, 1);\r
+                            offset += numberOfInterleavedComponents;\r
+                        }\r
+                        offset = numberOfInterleavedComponents - 1;\r
                     }\r
-                    offset = numberOfInterleavedComponents - 1;\r
+                } catch (IOException e) {\r
+                    throw new RuntimeException("Error processing transparency channel:", e);\r
                 }\r
-                dos.close();\r
-            } catch (IOException e) {\r
-                throw new RuntimeException("Error processing transparency channel:", e);\r
+                // set up alpha channel compression\r
+                FlateFilter transFlate;\r
+                try {\r
+                    transFlate = new FlateFilter();\r
+                    transFlate.setApplied(true);\r
+                    transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);\r
+                    transFlate.setColors(1);\r
+                    transFlate.setColumns(image.getSize().getWidthPx());\r
+                    transFlate.setBitsPerComponent(this.getBitsPerComponent());\r
+                } catch (PDFFilterException e) {\r
+                    throw new RuntimeException("FlateFilter configuration error", e);\r
+                }\r
+                BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),\r
+                        image.getSize().getHeightPx(), baos.toByteArray(), null);\r
+                IOUtils.closeQuietly(baos);\r
+                alphaMask.setPDFFilter(transFlate);\r
+                alphaMask.disallowMultipleFilters();\r
+                alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));\r
+                softMask = doc.addImage(null, alphaMask).makeReference();\r
             } finally {\r
                 IOUtils.closeQuietly(in);\r
+                IOUtils.closeQuietly(dos);\r
+                IOUtils.closeQuietly(baos);\r
             }\r
-            // set up alpha channel compression\r
-            FlateFilter transFlate;\r
-            try {\r
-                transFlate = new FlateFilter();\r
-                transFlate.setApplied(true);\r
-                transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);\r
-                transFlate.setColors(1);\r
-                transFlate.setColumns(image.getSize().getWidthPx());\r
-                transFlate.setBitsPerComponent(this.getBitsPerComponent());\r
-            } catch (PDFFilterException e) {\r
-                throw new RuntimeException("FlateFilter configuration error", e);\r
-            }\r
-            BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),\r
-                    image.getSize().getHeightPx(), baos.toByteArray(), null);\r
-            alphaMask.setPDFFilter(transFlate);\r
-            alphaMask.disallowMultipleFilters();\r
-            alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));\r
-            softMask = doc.addImage(null, alphaMask).makeReference();\r
         }\r
     }\r
 \r
index 11c3205e6ffefb5ca40fe280e994c9c6d2f04fd8..bc695f14a567f733ebdb3dbe14511693a6c8ca46 100644 (file)
@@ -57,4 +57,14 @@ public class PSImageFormResource extends PSResource {
         return this.uri;
     }
 
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return super.equals(obj);
+    }
+
 }
index d05ed8cc34a0d9a631f19563c1f4b261203ab421..950921e77c356f79682c414b91f66a72e9a51077 100644 (file)
@@ -41,14 +41,12 @@ abstract class RtfAfterBeforeBase
 extends RtfContainer
 implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContainer,
         IRtfTextrunContainer {
-    protected RtfAttributes attrib;
     private RtfParagraph para;
     private RtfExternalGraphic externalGraphic;
     private RtfTable table;
 
     RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
         super((RtfContainer)parent, w, attrs);
-        attrib = attrs;
     }
 
     public RtfParagraph newParagraph() throws IOException {
index e1ada281c54cc231ceb961c7d32f9db365ff3b13..f06486c2b3dee00771c953ec12c6e4bd31439dd9 100644 (file)
@@ -88,7 +88,7 @@ public class FopServlet extends HttpServlet {
     /** The FopFactory used to create Fop instances */
     protected FopFactory fopFactory;
     /** URIResolver for use by this servlet */
-    protected URIResolver uriResolver;
+    protected transient URIResolver uriResolver;
 
     /**
      * {@inheritDoc}
index 4441f6164062ee294bb753f07bb1943cf2ae013d..027c3503755b4bb6eb9d9e48641ba4f3dadef2d8 100644 (file)
@@ -31,6 +31,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.impl.SimpleLog;
 
 import org.apache.fop.apps.FOUserAgent;
@@ -295,11 +296,15 @@ public class TestConverter {
                                        outname + makeResultExtension());
 
             outputFile.getParentFile().mkdirs();
-            OutputStream outStream = new java.io.BufferedOutputStream(
-                                 new java.io.FileOutputStream(outputFile));
-            logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
-            inputHandler.renderTo(userAgent, outputFormat, outStream);
-            outStream.close();
+            OutputStream outStream = null;
+            try {
+                outStream = new java.io.BufferedOutputStream(
+                    new java.io.FileOutputStream(outputFile));
+                logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
+                inputHandler.renderTo(userAgent, outputFormat, outStream);
+            } finally {
+                IOUtils.closeQuietly(outStream);
+            }
 
             // check difference
             if (compare != null) {
index 6a959d75803cda530a02ea124e19094c4c7686ba..1f46b4abed5caf2ee387d9c6af364bcaf5cb1976 100644 (file)
@@ -25,6 +25,8 @@ import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
@@ -138,9 +140,14 @@ public class RunTest extends Task {
         // return;
         // } else {
         try {
-            ClassLoader loader = new URLClassLoader(createUrls(referenceJar));
+            final URL[] urls = createUrls(referenceJar);
+            ClassLoader loader = (ClassLoader)
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        return new URLClassLoader(urls);
+                    }
+                });
             boolean failed = false;
-
             try {
                 Class cla = Class.forName("org.apache.fop.apps.Fop", true,
                                     loader);
index 3e966d202a6485bdcc3ca5f7710315f7304fcc3d..ef4c2940644250a5b7e47def1f05f66c8c17b216 100644 (file)
@@ -548,7 +548,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable {
                 + ", fontName=" + fontName
                 + ", fontSize=" + fontSize
                 + ", lineWidth=" + lineWidth
-                + ", dashArray=" + dashArray
+                + ", dashArray=" + Arrays.toString(dashArray)
                 + ", transform=" + transform
                 + ", layer=" + layer;
         }
index 0ec56036740b4f2846a61b355ad3f8ae1f6c6ed7..a19d9c275b3f5dc8c4a6cd01ae2e319a4ae3c3f6 100644 (file)
@@ -82,4 +82,23 @@ public class ColorWithFallback extends ColorWithAlternatives {
         return this.fallback;
     }
 
+    @Override
+    public int hashCode() {
+        return super.hashCode() ^ fallback.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        } else if (!super.equals(obj)) {
+            return false;
+        } else if (obj instanceof ColorWithFallback) {
+            ColorWithFallback other = (ColorWithFallback) obj;
+            return other.fallback.equals(fallback);
+        } else {
+            return false;
+        }
+    }
+
 }