You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ss...@apache.org on 2015/05/22 15:26:13 UTC

svn commit: r1681108 [1/3] - in /xmlgraphics/commons/trunk: ./ src/java/org/apache/xmlgraphics/fonts/ src/java/org/apache/xmlgraphics/image/codec/png/ src/java/org/apache/xmlgraphics/image/codec/tiff/ src/java/org/apache/xmlgraphics/image/codec/util/ s...

Author: ssteiner
Date: Fri May 22 13:26:12 2015
New Revision: 1681108

URL: http://svn.apache.org/r1681108
Log:
Fix all findbugs warnings

Added:
    xmlgraphics/commons/trunk/findbugs-exclude.xml   (with props)
Modified:
    xmlgraphics/commons/trunk/build.xml
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/fonts/Glyphs.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGChunk.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGDecodeParam.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageDecoder.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageEncoder.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGRed.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGSuggestedPaletteEntry.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDecodeParam.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDirectory.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFEncodeParam.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFField.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImage.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageManager.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicy.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCache.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheStatistics.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageLoader.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/CompositeImageLoader.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBitmap2G2D.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBuffered2Rendered.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterRendered2PNG.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryEPS.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryInternalTIFF.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryPNG.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRawCCITTFax.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderInternalTIFF.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFax.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawJPEG.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/JPEGFile.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderJPEG.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageIOUtil.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderFactoryImageIO.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageProviderPipeline.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageRepresentation.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/internal/TIFFImageWriter.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParser.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/EPSDocumentGraphics2D.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSDictionary.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSState.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentBeginDocument.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentBeginResource.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentBoundingBox.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentHiResBoundingBox.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentLanguageLevel.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentPage.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/DSCCommentPages.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/events/PostScriptComment.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/tools/DSCTools.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/ImageIODebugUtil.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/UnitConv.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/WriterOutputStream.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/dijkstra/DijkstraAlgorithm.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/io/ASCII85OutputStream.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/io/Base64EncodeStream.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPPacketParser.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaRegistry.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/PipelineFactoryTestCase.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/ps/dsc/ListenerTestCase.java

Modified: xmlgraphics/commons/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/build.xml?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/build.xml (original)
+++ xmlgraphics/commons/trunk/build.xml Fri May 22 13:26:12 2015
@@ -683,4 +683,34 @@ NOTE:
 
   <target name="gump" depends="all, javadocs"/>
 
+<!-- =================================================================== -->
+<!-- Findbugs                                                            -->
+<!-- =================================================================== -->
+  <property name="findbugs.lib" value="${findbugs.home.dir}/lib"/>
+  <path id="libs-findbugs">
+    <fileset dir="${findbugs.lib}">
+      <include name="*.jar"/>
+    </fileset>
+  </path>
+  <target name="findbugs-avail" unless="findbugs.home.dir">
+    <echo message="Findbugs Support NOT Present. Please download it from http://findbugs.sf.net/ and set findbugs.home.dir in build-local.properties"/>
+  </target>
+  <target name="findbugs" depends="init, findbugs-avail, compile-java" if="findbugs.home.dir">
+    <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="libs-findbugs"/>
+    <findbugs home="${findbugs.home.dir}" output="text" reportLevel="low" effort="max" excludeFilter="findbugs-exclude.xml" jvmargs="-Xmx1024m" warningsProperty="findbugs.warnings">
+      <sourcePath path="${src.java.dir}"/>
+      <class location="${build.classes.dir}"/>
+      <auxClasspath>
+        <path refid="libs-build-classpath"/>
+        <path>
+          <fileset dir="${ant.library.dir}">
+            <include name="ant.jar"/>
+            <include name="ant-launcher.jar"/>
+          </fileset>
+        </path>
+      </auxClasspath>
+    </findbugs>
+    <fail if="findbugs.warnings"/>
+  </target>  
+
 </project>

Added: xmlgraphics/commons/trunk/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/findbugs-exclude.xml?rev=1681108&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/findbugs-exclude.xml (added)
+++ xmlgraphics/commons/trunk/findbugs-exclude.xml Fri May 22 13:26:12 2015
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FindBugsFilter>
+  <Match>
+    <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+  </Match>
+  <Match>
+    <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFEncodeParam"/>
+    <Field name="extraFields"/>
+    <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+  </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.fonts.Glyphs"/>
+     <Bug pattern="MS_MUTABLE_ARRAY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.png.PNGImage"/>
+     <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.png.PNGImageEncoder"/>
+     <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.png.PNGRed"/>
+     <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.util.SeekableStream"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFDirectory"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFEncodeParam"/>
+     <Bug pattern="SE_BAD_FIELD"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFFaxDecoder"/>
+     <Field name="data"/>
+     <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFLZWDecoder"/>
+     <Field name="uncompData"/>
+     <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.impl.ImageConverterBitmap2G2D$Graphics2DImagePainterImpl"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.ps.PSTilingPattern"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>   
+   <Match>
+     <Class name="org.apache.xmlgraphics.ps.PSImageUtils"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.ColorUtil"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>  
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>     
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.ps.PSTilingPattern"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.ps.PSState"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.NamedColorSpace"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>       
+   <Match>
+     <Class name="org.apache.xmlgraphics.util.Service"/>
+     <Bug pattern="DE_MIGHT_IGNORE"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.util.SimpleRenderedImage"/>
+     <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry"/>
+     <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.xmlgraphics.xmp.XMPSchemaAdapter"/>
+     <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.xmlgraphics.util.Service"/>
+     <Bug pattern="REC_CATCH_EXCEPTION"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.GraphicContext"/>
+     <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
+   </Match>       
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.impl.ImageLoaderEPS"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.impl.JPEGFile"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.util.ImageUtil"/>
+     <Bug pattern="RR_NOT_CHECKED"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.profile.NamedColorProfileParser"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.profile.NamedColorProfileParser"/>
+     <Bug pattern="SR_NOT_CHECKED"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFField"/>
+     <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.util.FileCacheSeekableStream"/>
+     <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.java2d.color.ColorWithAlternatives"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.ps.PSPageDeviceDictionary"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.ps.PSProcSet"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFImage"/>
+   </Match>   
+   <Match>
+     <Class name="org.apache.xmlgraphics.io.XmlSourceUtil"/>
+     <Bug pattern="REC_CATCH_EXCEPTION"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.TIFFImage"/>
+     <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
+   </Match> 
+   <Match>
+     <Class name="org.apache.xmlgraphics.util.io.ASCII85Constants"/>
+     <Bug pattern="MS_OOI_PKGPROTECT"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry"/>
+     <Bug pattern="IS2_INCONSISTENT_SYNC"/>
+   </Match>
+   <Match>
+       <Class name="org.apache.xmlgraphics.image.writer.imageio.ImageIOImageWriter"/>
+     <!-- <Bug pattern="NM_VERY_CONFUSING"/> -->
+   </Match>
+   <Match>
+       <Class name="org.apache.xmlgraphics.image.loader.ImageFlavor"/>
+     <!-- <Bug pattern="NM_VERY_CONFUSING"/> -->
+   </Match>   
+   <Match>
+     <Class name="org.apache.xmlgraphics.fonts.Glyphs"/>
+     <Bug pattern="MS_PKGPROTECT"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.ps.PSGenerator"/>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.xmlgraphics.image.codec.tiff.ImageInfo"/>
+     <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+   </Match>   
+   
+</FindBugsFilter>

Propchange: xmlgraphics/commons/trunk/findbugs-exclude.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/fonts/Glyphs.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/fonts/Glyphs.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/fonts/Glyphs.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/fonts/Glyphs.java Fri May 22 13:26:12 2015
@@ -659,10 +659,14 @@ public final class Glyphs {
         try {
             BufferedReader reader = new BufferedReader(new InputStreamReader(in, "US-ASCII"));
             String line;
-            while ((line = reader.readLine()) != null) {
-                if (!line.startsWith("#")) {
-                    lines.add(line);
+            try {
+                while ((line = reader.readLine()) != null) {
+                    if (!line.startsWith("#")) {
+                        lines.add(line);
+                    }
                 }
+            } finally {
+                reader.close();
             }
         } catch (UnsupportedEncodingException uee) {
             throw new RuntimeException("Incompatible JVM! US-ASCII encoding is not supported."

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGChunk.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGChunk.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGChunk.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGChunk.java Fri May 22 13:26:12 2015
@@ -33,7 +33,7 @@ public class PNGChunk {
     String typeString;
 
     /** logger */
-    protected static Log log = LogFactory.getLog(PNGChunk.class);
+    protected static final Log log = LogFactory.getLog(PNGChunk.class);
 
     /**
      * See http://en.wikipedia.org/wiki/Portable_Network_Graphics for a light explanation;
@@ -64,7 +64,7 @@ public class PNGChunk {
     public PNGChunk(int length, int type, byte[] data, int crc) {
         this.length = length;
         this.type = type;
-        this.data = data;
+        this.data = data.clone();
         this.crc = crc;
         this.typeString = typeIntToString(this.type);
     }
@@ -82,7 +82,7 @@ public class PNGChunk {
     }
 
     public byte[] getData() {
-        return data;
+        return data.clone();
     }
 
     public byte getByte(int offset) {
@@ -167,10 +167,10 @@ public class PNGChunk {
     public static boolean skipChunk(DataInputStream distream) {
         try {
             int length = distream.readInt();
-            int type = distream.readInt();
+            distream.readInt();
             // is this really faster than reading?
             int skipped = distream.skipBytes(length);
-            int crc = distream.readInt();
+            distream.readInt();
             if (skipped != length) {
                 log.warn("Incorrect number of bytes skipped.");
                 return false;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGDecodeParam.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGDecodeParam.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGDecodeParam.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGDecodeParam.java Fri May 22 13:26:12 2015
@@ -78,6 +78,8 @@ import org.apache.xmlgraphics.image.code
  */
 public class PNGDecodeParam implements ImageDecodeParam {
 
+    private static final long serialVersionUID = 3957265194926624623L;
+
     /**
      * Constructs a default instance of <code>PNGDecodeParam</code>.
      */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java Fri May 22 13:26:12 2015
@@ -45,6 +45,7 @@ import org.apache.xmlgraphics.image.code
  * be removed or changed in future releases of JAI.</b>
  */
 public abstract class PNGEncodeParam implements ImageEncodeParam {
+    private static final long serialVersionUID = -7851509538552141263L;
 
     /** Constant for use with the sRGB chunk. */
     public static final int INTENT_PERCEPTUAL = 0;
@@ -110,6 +111,8 @@ public abstract class PNGEncodeParam imp
 
     public static class Palette extends PNGEncodeParam {
 
+        private static final long serialVersionUID = -5181545170427733891L;
+
         /** Constructs an instance of <code>PNGEncodeParam.Palette</code>. */
         public Palette() { }
 
@@ -280,6 +283,8 @@ public abstract class PNGEncodeParam imp
 
     public static class Gray extends PNGEncodeParam {
 
+        private static final long serialVersionUID = -2055439792025795274L;
+
         /** Constructs an instance of <code>PNGEncodeParam.Gray</code>. */
         public Gray() { }
 
@@ -444,6 +449,8 @@ public abstract class PNGEncodeParam imp
 
     public static class RGB extends PNGEncodeParam {
 
+        private static final long serialVersionUID = -8918762026006670891L;
+
         /** Constructs an instance of <code>PNGEncodeParam.RGB</code>. */
         public RGB() { }
 
@@ -491,7 +498,7 @@ public abstract class PNGEncodeParam imp
             if (rgb.length != 3) {
                 throw new IllegalArgumentException(PropertyUtil.getString("PNGEncodeParam27"));
             }
-            backgroundRGB = rgb;
+            backgroundRGB = rgb.clone();
             backgroundSet = true;
         }
 
@@ -507,7 +514,7 @@ public abstract class PNGEncodeParam imp
             if (!backgroundSet) {
                 throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam9"));
             }
-            return backgroundRGB;
+            return backgroundRGB.clone();
         }
 
         // tRNS chunk
@@ -776,7 +783,7 @@ public abstract class PNGEncodeParam imp
         if (!paletteHistogramSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam14"));
         }
-        return paletteHistogram;
+        return paletteHistogram.clone();
     }
 
     /**
@@ -1068,7 +1075,7 @@ public abstract class PNGEncodeParam imp
      * <p> The 'tEXt' chunk will encode this information.
      */
     public void setText(String[] text) {
-        this.text = text;
+        this.text = text.clone();
         textSet = true;
     }
 
@@ -1085,7 +1092,7 @@ public abstract class PNGEncodeParam imp
         if (!textSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam20"));
         }
-        return text;
+        return text.clone();
     }
 
     /**
@@ -1117,7 +1124,7 @@ public abstract class PNGEncodeParam imp
      * <p> The 'tIME' chunk will encode this information.
      */
     public void setModificationTime(Date modificationTime) {
-        this.modificationTime = modificationTime;
+        this.modificationTime = (Date) modificationTime.clone();
         modificationTimeSet = true;
     }
 
@@ -1133,7 +1140,7 @@ public abstract class PNGEncodeParam imp
         if (!modificationTimeSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam21"));
         }
-        return modificationTime;
+        return (Date) modificationTime.clone();
     }
 
     /**
@@ -1182,7 +1189,7 @@ public abstract class PNGEncodeParam imp
      * <p> The 'zTXt' chunk will encode this information.
      */
     public void setCompressedText(String[] text) {
-        this.zText = text;
+        this.zText = text.clone();
         zTextSet = true;
     }
 
@@ -1201,7 +1208,7 @@ public abstract class PNGEncodeParam imp
         if (!zTextSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam22"));
         }
-        return zText;
+        return zText.clone();
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageDecoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageDecoder.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageDecoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageDecoder.java Fri May 22 13:26:12 2015
@@ -44,6 +44,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
+import java.util.Locale;
 import java.util.TimeZone;
 import java.util.zip.Inflater;
 import java.util.zip.InflaterInputStream;
@@ -329,7 +330,7 @@ class PNGImage extends SimpleRenderedIma
         }
 
         do {
-            try {
+//            try {
                 PNGChunk chunk;
 
                 String chunkType = PNGChunk.getChunkType(distream);
@@ -344,7 +345,13 @@ class PNGImage extends SimpleRenderedIma
                     streamVec.add(new ByteArrayInputStream(chunk.getData()));
                 } else if (chunkType.equals(PNGChunk.ChunkType.IEND.name())) {
                     chunk = PNGChunk.readChunk(distream);
-                    parse_IEND_chunk(chunk);
+                    try {
+                        parse_IEND_chunk(chunk);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        String msg = PropertyUtil.getString("PNGImageDecoder2");
+                        throw new RuntimeException(msg);
+                    }
                     break; // fall through to the bottom
                 } else if (chunkType.equals(PNGChunk.ChunkType.bKGD.name())) {
                     chunk = PNGChunk.readChunk(distream);
@@ -393,14 +400,14 @@ class PNGImage extends SimpleRenderedIma
                     }
                     if (emitProperties) {
                         String key = "chunk_" + chunkIndex++ + ':' + type;
-                        properties.put(key.toLowerCase(), data);
+                        properties.put(key.toLowerCase(Locale.getDefault()), data);
                     }
                 }
-            } catch (Exception e) {
-                e.printStackTrace();
-                String msg = PropertyUtil.getString("PNGImageDecoder2");
-                throw new RuntimeException(msg);
-            }
+//            } catch (Exception e) {
+//                e.printStackTrace();
+//                String msg = PropertyUtil.getString("PNGImageDecoder2");
+//                throw new RuntimeException(msg);
+//            }
         } while (true);
 
         // Final post-processing
@@ -484,7 +491,7 @@ class PNGImage extends SimpleRenderedIma
             encodeParam.setBitDepth(bitDepth);
         }
         if (emitProperties) {
-            properties.put("bit_depth", new Integer(bitDepth));
+            properties.put("bit_depth", bitDepth);
         }
 
         if (performGammaCorrection) {
@@ -494,7 +501,7 @@ class PNGImage extends SimpleRenderedIma
                 encodeParam.setGamma(gamma);
             }
             if (emitProperties) {
-                properties.put("gamma", new Float(gamma));
+                properties.put("gamma", gamma);
             }
         }
 
@@ -622,7 +629,7 @@ class PNGImage extends SimpleRenderedIma
             textArray[2 * i + 1] = val;
             if (emitProperties) {
                 String uniqueKey = "text_" + i + ':' + key;
-                properties.put(uniqueKey.toLowerCase(), val);
+                properties.put(uniqueKey.toLowerCase(Locale.getDefault()), val);
             }
         }
         if (encodeParam != null) {
@@ -639,7 +646,7 @@ class PNGImage extends SimpleRenderedIma
             ztextArray[2 * i + 1] = val;
             if (emitProperties) {
                 String uniqueKey = "ztext_" + i + ':' + key;
-                properties.put(uniqueKey.toLowerCase(), val);
+                properties.put(uniqueKey.toLowerCase(Locale.getDefault()), val);
             }
         }
         if (encodeParam != null) {
@@ -968,14 +975,14 @@ class PNGImage extends SimpleRenderedIma
             encodeParam.setChromaticity(chromaticity);
         }
         if (emitProperties) {
-            properties.put("white_point_x", new Float(chromaticity[0]));
-            properties.put("white_point_y", new Float(chromaticity[1]));
-            properties.put("red_x", new Float(chromaticity[2]));
-            properties.put("red_y", new Float(chromaticity[3]));
-            properties.put("green_x", new Float(chromaticity[4]));
-            properties.put("green_y", new Float(chromaticity[5]));
-            properties.put("blue_x", new Float(chromaticity[6]));
-            properties.put("blue_y", new Float(chromaticity[7]));
+            properties.put("white_point_x", chromaticity[0]);
+            properties.put("white_point_y", chromaticity[1]);
+            properties.put("red_x", chromaticity[2]);
+            properties.put("red_y", chromaticity[3]);
+            properties.put("green_x", chromaticity[4]);
+            properties.put("green_y", chromaticity[5]);
+            properties.put("blue_x", chromaticity[6]);
+            properties.put("blue_y", chromaticity[7]);
         }
     }
 
@@ -993,7 +1000,7 @@ class PNGImage extends SimpleRenderedIma
             encodeParam.setGamma(fileGamma * exp);
         }
         if (emitProperties) {
-            properties.put("gamma", new Float(fileGamma * exp));
+            properties.put("gamma", fileGamma * exp);
         }
     }
 
@@ -1015,13 +1022,13 @@ class PNGImage extends SimpleRenderedIma
     }
 
     private void parse_iCCP_chunk(PNGChunk chunk) {
-        String name = "";  // todo simplify this
-        byte b;
+//        String name = "";  // todo simplify this
+//        byte b;
 
-        int textIndex = 0;
-        while ((b = chunk.getByte(textIndex++)) != 0) {
-            name += (char)b;
-        }
+//        int textIndex = 0;
+//        while ((b = chunk.getByte(textIndex++)) != 0) {
+//            name += (char)b;
+//        }
     }
 
     private void parse_pHYs_chunk(PNGChunk chunk) {
@@ -1035,10 +1042,10 @@ class PNGImage extends SimpleRenderedIma
                                              unitSpecifier);
         }
         if (emitProperties) {
-            properties.put("x_pixels_per_unit", new Integer(xPixelsPerUnit));
-            properties.put("y_pixels_per_unit", new Integer(yPixelsPerUnit));
+            properties.put("x_pixels_per_unit", xPixelsPerUnit);
+            properties.put("y_pixels_per_unit", yPixelsPerUnit);
             properties.put("pixel_aspect_ratio",
-                           new Float((float)xPixelsPerUnit / yPixelsPerUnit));
+                    (float) xPixelsPerUnit / yPixelsPerUnit);
             if (unitSpecifier == 1) {
                 properties.put("pixel_units", "Meters");
             } else if (unitSpecifier != 0) {
@@ -1100,15 +1107,15 @@ class PNGImage extends SimpleRenderedIma
                 encodeParam.setChromaticity(chromaticity);
             }
             if (emitProperties) {
-                properties.put("gamma", new Float(gamma));
-                properties.put("white_point_x", new Float(chromaticity[0]));
-                properties.put("white_point_y", new Float(chromaticity[1]));
-                properties.put("red_x", new Float(chromaticity[2]));
-                properties.put("red_y", new Float(chromaticity[3]));
-                properties.put("green_x", new Float(chromaticity[4]));
-                properties.put("green_y", new Float(chromaticity[5]));
-                properties.put("blue_x", new Float(chromaticity[6]));
-                properties.put("blue_y", new Float(chromaticity[7]));
+                properties.put("gamma", gamma);
+                properties.put("white_point_x", chromaticity[0]);
+                properties.put("white_point_y", chromaticity[1]);
+                properties.put("red_x", chromaticity[2]);
+                properties.put("red_y", chromaticity[3]);
+                properties.put("green_x", chromaticity[4]);
+                properties.put("green_y", chromaticity[5]);
+                properties.put("blue_x", chromaticity[6]);
+                properties.put("blue_y", chromaticity[7]);
             }
         }
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageEncoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageEncoder.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageEncoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGImageEncoder.java Fri May 22 13:26:12 2015
@@ -333,16 +333,19 @@ public class PNGImageEncoder extends Ima
 
     private void writeIHDR() throws IOException {
         ChunkStream cs = new ChunkStream("IHDR");
-        cs.writeInt(width);
-        cs.writeInt(height);
-        cs.writeByte((byte)bitDepth);
-        cs.writeByte((byte)colorType);
-        cs.writeByte((byte)0);
-        cs.writeByte((byte)0);
-        cs.writeByte(interlace ? (byte)1 : (byte)0);
+        try {
+            cs.writeInt(width);
+            cs.writeInt(height);
+            cs.writeByte((byte)bitDepth);
+            cs.writeByte((byte)colorType);
+            cs.writeByte((byte)0);
+            cs.writeByte((byte)0);
+            cs.writeByte(interlace ? (byte)1 : (byte)0);
 
-        cs.writeToStream(dataOutput);
-        cs.close();
+            cs.writeToStream(dataOutput);
+        } finally {
+            cs.close();
+        }
     }
 
     private byte[] prevRow;
@@ -528,8 +531,11 @@ public class PNGImageEncoder extends Ima
 
     private void writeIEND() throws IOException {
         ChunkStream cs = new ChunkStream("IEND");
-        cs.writeToStream(dataOutput);
-        cs.close();
+        try {
+            cs.writeToStream(dataOutput);
+        } finally {
+            cs.close();
+        }
     }
 
     private static final float[] SRGB_CHROMA = {
@@ -539,71 +545,83 @@ public class PNGImageEncoder extends Ima
     private void writeCHRM() throws IOException {
         if (param.isChromaticitySet() || param.isSRGBIntentSet()) {
             ChunkStream cs = new ChunkStream("cHRM");
+            try {
+                float[] chroma;
+                if (!param.isSRGBIntentSet()) {
+                    chroma = param.getChromaticity();
+                } else {
+                    chroma = SRGB_CHROMA; // SRGB chromaticities
+                }
 
-            float[] chroma;
-            if (!param.isSRGBIntentSet()) {
-                chroma = param.getChromaticity();
-            } else {
-                chroma = SRGB_CHROMA; // SRGB chromaticities
-            }
-
-            for (int i = 0; i < 8; i++) {
-                cs.writeInt((int)(chroma[i] * 100000));
+                for (int i = 0; i < 8; i++) {
+                    cs.writeInt((int)(chroma[i] * 100000));
+                }
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
             }
-            cs.writeToStream(dataOutput);
-            cs.close();
         }
     }
 
     private void writeGAMA() throws IOException {
         if (param.isGammaSet() || param.isSRGBIntentSet()) {
             ChunkStream cs = new ChunkStream("gAMA");
-
-            float gamma;
-            if (!param.isSRGBIntentSet()) {
-                gamma = param.getGamma();
-            } else {
-                gamma = 1.0F / 2.2F; // SRGB gamma
-            }
-            // TD should include the .5 but causes regard to say
-            // everything is different.
-            cs.writeInt((int)(gamma * 100000/*+0.5*/));
-            cs.writeToStream(dataOutput);
-            cs.close();
+            try {
+                float gamma;
+                if (!param.isSRGBIntentSet()) {
+                    gamma = param.getGamma();
+                } else {
+                    gamma = 1.0F / 2.2F; // SRGB gamma
+                }
+                // TD should include the .5 but causes regard to say
+                // everything is different.
+                cs.writeInt((int)(gamma * 100000/*+0.5*/));
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
     private void writeICCP() throws IOException {
         if (param.isICCProfileDataSet()) {
             ChunkStream cs = new ChunkStream("iCCP");
-            byte[] iccProfileData = param.getICCProfileData();
-            cs.write(iccProfileData);
-            cs.writeToStream(dataOutput);
-            cs.close();
+            try {
+                byte[] iccProfileData = param.getICCProfileData();
+                cs.write(iccProfileData);
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
     private void writeSBIT() throws IOException {
         if (param.isSignificantBitsSet()) {
             ChunkStream cs = new ChunkStream("sBIT");
-            int[] significantBits = param.getSignificantBits();
-            int len = significantBits.length;
-            for (int i = 0; i < len; i++) {
-                cs.writeByte(significantBits[i]);
+            try {
+                int[] significantBits = param.getSignificantBits();
+                int len = significantBits.length;
+                for (int i = 0; i < len; i++) {
+                    cs.writeByte(significantBits[i]);
+                }
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
             }
-            cs.writeToStream(dataOutput);
-            cs.close();
         }
     }
 
     private void writeSRGB() throws IOException {
         if (param.isSRGBIntentSet()) {
             ChunkStream cs = new ChunkStream("sRGB");
-
-            int intent = param.getSRGBIntent();
-            cs.write(intent);
-            cs.writeToStream(dataOutput);
-            cs.close();
+            try {
+                int intent = param.getSRGBIntent();
+                cs.write(intent);
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
@@ -613,58 +631,65 @@ public class PNGImageEncoder extends Ima
         }
 
         ChunkStream cs = new ChunkStream("PLTE");
-        for (int i = 0; i < redPalette.length; i++) {
-            cs.writeByte(redPalette[i]);
-            cs.writeByte(greenPalette[i]);
-            cs.writeByte(bluePalette[i]);
-        }
+        try {
+            for (int i = 0; i < redPalette.length; i++) {
+                cs.writeByte(redPalette[i]);
+                cs.writeByte(greenPalette[i]);
+                cs.writeByte(bluePalette[i]);
+            }
 
-        cs.writeToStream(dataOutput);
-        cs.close();
+            cs.writeToStream(dataOutput);
+        } finally {
+            cs.close();
+        }
     }
 
     private void writeBKGD() throws IOException {
         if (param.isBackgroundSet()) {
             ChunkStream cs = new ChunkStream("bKGD");
+            try {
+                switch (colorType) {
+                case PNG_COLOR_GRAY:
+                case PNG_COLOR_GRAY_ALPHA:
+                    int gray = ((PNGEncodeParam.Gray)param).getBackgroundGray();
+                    cs.writeShort(gray);
+                    break;
 
-            switch (colorType) {
-            case PNG_COLOR_GRAY:
-            case PNG_COLOR_GRAY_ALPHA:
-                int gray = ((PNGEncodeParam.Gray)param).getBackgroundGray();
-                cs.writeShort(gray);
-                break;
+                case PNG_COLOR_PALETTE:
+                    int index =
+                       ((PNGEncodeParam.Palette)param).getBackgroundPaletteIndex();
+                    cs.writeByte(index);
+                    break;
 
-            case PNG_COLOR_PALETTE:
-                int index =
-                   ((PNGEncodeParam.Palette)param).getBackgroundPaletteIndex();
-                cs.writeByte(index);
-                break;
+                case PNG_COLOR_RGB:
+                case PNG_COLOR_RGB_ALPHA:
+                    int[] rgb = ((PNGEncodeParam.RGB)param).getBackgroundRGB();
+                    cs.writeShort(rgb[0]);
+                    cs.writeShort(rgb[1]);
+                    cs.writeShort(rgb[2]);
+                    break;
+                }
 
-            case PNG_COLOR_RGB:
-            case PNG_COLOR_RGB_ALPHA:
-                int[] rgb = ((PNGEncodeParam.RGB)param).getBackgroundRGB();
-                cs.writeShort(rgb[0]);
-                cs.writeShort(rgb[1]);
-                cs.writeShort(rgb[2]);
-                break;
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
             }
-
-            cs.writeToStream(dataOutput);
-            cs.close();
         }
     }
 
     private void writeHIST() throws IOException {
         if (param.isPaletteHistogramSet()) {
             ChunkStream cs = new ChunkStream("hIST");
+            try {
+                int[] hist = param.getPaletteHistogram();
+                for (int i = 0; i < hist.length; i++) {
+                    cs.writeShort(hist[i]);
+                }
 
-            int[] hist = param.getPaletteHistogram();
-            for (int i = 0; i < hist.length; i++) {
-                cs.writeShort(hist[i]);
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
             }
-
-            cs.writeToStream(dataOutput);
-            cs.close();
         }
     }
 
@@ -673,25 +698,27 @@ public class PNGImageEncoder extends Ima
             && (colorType != PNG_COLOR_GRAY_ALPHA)
             && (colorType != PNG_COLOR_RGB_ALPHA)) {
             ChunkStream cs = new ChunkStream("tRNS");
+            try {
+                if (param instanceof PNGEncodeParam.Palette) {
+                    byte[] t =
+                        ((PNGEncodeParam.Palette)param).getPaletteTransparency();
+                    for (int i = 0; i < t.length; i++) {
+                        cs.writeByte(t[i]);
+                    }
+                } else if (param instanceof PNGEncodeParam.Gray) {
+                    int t = ((PNGEncodeParam.Gray)param).getTransparentGray();
+                    cs.writeShort(t);
+                } else if (param instanceof PNGEncodeParam.RGB) {
+                    int[] t = ((PNGEncodeParam.RGB)param).getTransparentRGB();
+                    cs.writeShort(t[0]);
+                    cs.writeShort(t[1]);
+                    cs.writeShort(t[2]);
+                }
 
-            if (param instanceof PNGEncodeParam.Palette) {
-                byte[] t =
-                    ((PNGEncodeParam.Palette)param).getPaletteTransparency();
-                for (int i = 0; i < t.length; i++) {
-                    cs.writeByte(t[i]);
-                }
-            } else if (param instanceof PNGEncodeParam.Gray) {
-                int t = ((PNGEncodeParam.Gray)param).getTransparentGray();
-                cs.writeShort(t);
-            } else if (param instanceof PNGEncodeParam.RGB) {
-                int[] t = ((PNGEncodeParam.RGB)param).getTransparentRGB();
-                cs.writeShort(t[0]);
-                cs.writeShort(t[1]);
-                cs.writeShort(t[2]);
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
             }
-
-            cs.writeToStream(dataOutput);
-            cs.close();
         } else if (colorType == PNG_COLOR_PALETTE) {
             int lastEntry = Math.min(255, alphaPalette.length - 1);
             int nonOpaque;
@@ -703,11 +730,14 @@ public class PNGImageEncoder extends Ima
 
             if (nonOpaque >= 0) {
                 ChunkStream cs = new ChunkStream("tRNS");
-                for (int i = 0; i <= nonOpaque; i++) {
-                    cs.writeByte(alphaPalette[i]);
+                try {
+                    for (int i = 0; i <= nonOpaque; i++) {
+                        cs.writeByte(alphaPalette[i]);
+                    }
+                    cs.writeToStream(dataOutput);
+                } finally {
+                    cs.close();
                 }
-                cs.writeToStream(dataOutput);
-                cs.close();
             }
         }
     }
@@ -715,54 +745,60 @@ public class PNGImageEncoder extends Ima
     private void writePHYS() throws IOException {
         if (param.isPhysicalDimensionSet()) {
             ChunkStream cs = new ChunkStream("pHYs");
+            try {
+                int[] dims = param.getPhysicalDimension();
+                cs.writeInt(dims[0]);
+                cs.writeInt(dims[1]);
+                cs.writeByte((byte)dims[2]);
 
-            int[] dims = param.getPhysicalDimension();
-            cs.writeInt(dims[0]);
-            cs.writeInt(dims[1]);
-            cs.writeByte((byte)dims[2]);
-
-            cs.writeToStream(dataOutput);
-            cs.close();
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
     private void writeSPLT() throws IOException {
         if (param.isSuggestedPaletteSet()) {
             ChunkStream cs = new ChunkStream("sPLT");
+            try {
+                System.out.println("sPLT not supported yet.");
 
-            System.out.println("sPLT not supported yet.");
-
-            cs.writeToStream(dataOutput);
-            cs.close();
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
     private void writeTIME() throws IOException {
         if (param.isModificationTimeSet()) {
             ChunkStream cs = new ChunkStream("tIME");
+            try {
+                Date date = param.getModificationTime();
+                TimeZone gmt = TimeZone.getTimeZone("GMT");
+
+                GregorianCalendar cal = new GregorianCalendar(gmt);
+                cal.setTime(date);
+
+                int year = cal.get(Calendar.YEAR);
+                int month = cal.get(Calendar.MONTH);
+                int day = cal.get(Calendar.DAY_OF_MONTH);
+                int hour = cal.get(Calendar.HOUR_OF_DAY);
+                int minute = cal.get(Calendar.MINUTE);
+                int second = cal.get(Calendar.SECOND);
+
+                cs.writeShort(year);
+                cs.writeByte(month + 1);
+                cs.writeByte(day);
+                cs.writeByte(hour);
+                cs.writeByte(minute);
+                cs.writeByte(second);
 
-            Date date = param.getModificationTime();
-            TimeZone gmt = TimeZone.getTimeZone("GMT");
-
-            GregorianCalendar cal = new GregorianCalendar(gmt);
-            cal.setTime(date);
-
-            int year = cal.get(Calendar.YEAR);
-            int month = cal.get(Calendar.MONTH);
-            int day = cal.get(Calendar.DAY_OF_MONTH);
-            int hour = cal.get(Calendar.HOUR_OF_DAY);
-            int minute = cal.get(Calendar.MINUTE);
-            int second = cal.get(Calendar.SECOND);
-
-            cs.writeShort(year);
-            cs.writeByte(month + 1);
-            cs.writeByte(day);
-            cs.writeByte(hour);
-            cs.writeByte(minute);
-            cs.writeByte(second);
-
-            cs.writeToStream(dataOutput);
-            cs.close();
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 
@@ -771,17 +807,19 @@ public class PNGImageEncoder extends Ima
             String[] text = param.getText();
 
             for (int i = 0; i < text.length / 2; i++) {
-                byte[] keyword = text[2 * i].getBytes();
-                byte[] value = text[2 * i + 1].getBytes();
+                byte[] keyword = text[2 * i].getBytes("UTF-8");
+                byte[] value = text[2 * i + 1].getBytes("UTF-8");
 
                 ChunkStream cs = new ChunkStream("tEXt");
-
-                cs.write(keyword, 0, Math.min(keyword.length, 79));
-                cs.write(0);
-                cs.write(value);
-
-                cs.writeToStream(dataOutput);
-                cs.close();
+                try {
+                    cs.write(keyword, 0, Math.min(keyword.length, 79));
+                    cs.write(0);
+                    cs.write(value);
+
+                    cs.writeToStream(dataOutput);
+                } finally {
+                    cs.close();
+                }
             }
         }
     }
@@ -791,22 +829,27 @@ public class PNGImageEncoder extends Ima
             String[] text = param.getCompressedText();
 
             for (int i = 0; i < text.length / 2; i++) {
-                byte[] keyword = text[2 * i].getBytes();
-                byte[] value = text[2 * i + 1].getBytes();
+                byte[] keyword = text[2 * i].getBytes("UTF-8");
+                byte[] value = text[2 * i + 1].getBytes("UTF-8");
 
                 ChunkStream cs = new ChunkStream("zTXt");
+                try {
+                    cs.write(keyword, 0, Math.min(keyword.length, 79));
+                    cs.write(0);
+                    cs.write(0);
+
+                    DeflaterOutputStream dos = new DeflaterOutputStream(cs);
+                    try {
+                        dos.write(value);
+                        dos.finish();
+                    } finally {
+                        dos.close();
+                    }
 
-                cs.write(keyword, 0, Math.min(keyword.length, 79));
-                cs.write(0);
-                cs.write(0);
-
-                DeflaterOutputStream dos = new DeflaterOutputStream(cs);
-                dos.write(value);
-                dos.finish();
-                dos.close();
-
-                cs.writeToStream(dataOutput);
-                cs.close();
+                    cs.writeToStream(dataOutput);
+                } finally {
+                    cs.close();
+                }
             }
         }
     }
@@ -818,9 +861,12 @@ public class PNGImageEncoder extends Ima
             byte[] data = param.getPrivateChunkData(i);
 
             ChunkStream cs = new ChunkStream(type);
-            cs.write(data);
-            cs.writeToStream(dataOutput);
-            cs.close();
+            try {
+                cs.write(data);
+                cs.writeToStream(dataOutput);
+            } finally {
+                cs.close();
+            }
         }
     }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGRed.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGRed.java Fri May 22 13:26:12 2015
@@ -45,6 +45,7 @@ import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
 import java.util.zip.Inflater;
@@ -73,7 +74,6 @@ public class PNGRed extends AbstractRed
         int length;
         int type;
         byte[] data;
-        int crc;
 
         String typeString;
 
@@ -81,7 +81,6 @@ public class PNGRed extends AbstractRed
             this.length = length;
             this.type = type;
             this.data = data;
-            this.crc = crc;
 
             typeString = "";
             typeString += (char)(type >> 24);
@@ -127,7 +126,7 @@ public class PNGRed extends AbstractRed
         }
 
         public String getString4(int offset) {
-            String s = new String();
+            String s = "";
             s += (char)data[offset];
             s += (char)data[offset + 1];
             s += (char)data[offset + 2];
@@ -388,90 +387,83 @@ public class PNGRed extends AbstractRed
             properties.put("file_type", "PNG v. 1.0");
         }
 
-        try {
-            long magic = distream.readLong();
-            if (magic != 0x89504e470d0a1a0aL) {
-                String msg = PropertyUtil.getString("PNGImageDecoder0");
-                throw new RuntimeException(msg);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            String msg = PropertyUtil.getString("PNGImageDecoder1");
+        long magic = distream.readLong();
+        if (magic != 0x89504e470d0a1a0aL) {
+            String msg = PropertyUtil.getString("PNGImageDecoder0");
             throw new RuntimeException(msg);
         }
 
         do {
-            try {
-                PNGChunk chunk;
+            PNGChunk chunk;
 
-                String chunkType = getChunkType(distream);
-                if (chunkType.equals("IHDR")) {
-                    chunk = readChunk(distream);
-                    parse_IHDR_chunk(chunk);
-                } else if (chunkType.equals("PLTE")) {
-                    chunk = readChunk(distream);
-                    parse_PLTE_chunk(chunk);
-                } else if (chunkType.equals("IDAT")) {
-                    chunk = readChunk(distream);
-                    streamVec.add(new ByteArrayInputStream(chunk.getData()));
-                } else if (chunkType.equals("IEND")) {
-                    chunk = readChunk(distream);
+            String chunkType = getChunkType(distream);
+            if (chunkType.equals("IHDR")) {
+                chunk = readChunk(distream);
+                parse_IHDR_chunk(chunk);
+            } else if (chunkType.equals("PLTE")) {
+                chunk = readChunk(distream);
+                parse_PLTE_chunk(chunk);
+            } else if (chunkType.equals("IDAT")) {
+                chunk = readChunk(distream);
+                streamVec.add(new ByteArrayInputStream(chunk.getData()));
+            } else if (chunkType.equals("IEND")) {
+                chunk = readChunk(distream);
+                try {
                     parse_IEND_chunk(chunk);
-                    break; // fall through to the bottom
-                } else if (chunkType.equals("bKGD")) {
-                    chunk = readChunk(distream);
-                    parse_bKGD_chunk(chunk);
-                } else if (chunkType.equals("cHRM")) {
-                    chunk = readChunk(distream);
-                    parse_cHRM_chunk(chunk);
-                } else if (chunkType.equals("gAMA")) {
-                    chunk = readChunk(distream);
-                    parse_gAMA_chunk(chunk);
-                } else if (chunkType.equals("hIST")) {
-                    chunk = readChunk(distream);
-                    parse_hIST_chunk(chunk);
-                } else if (chunkType.equals("iCCP")) {
-                    chunk = readChunk(distream);
-                    parse_iCCP_chunk(chunk);
-                } else if (chunkType.equals("pHYs")) {
-                    chunk = readChunk(distream);
-                    parse_pHYs_chunk(chunk);
-                } else if (chunkType.equals("sBIT")) {
-                    chunk = readChunk(distream);
-                    parse_sBIT_chunk(chunk);
-                } else if (chunkType.equals("sRGB")) {
-                    chunk = readChunk(distream);
-                    parse_sRGB_chunk(chunk);
-                } else if (chunkType.equals("tEXt")) {
-                    chunk = readChunk(distream);
-                    parse_tEXt_chunk(chunk);
-                } else if (chunkType.equals("tIME")) {
-                    chunk = readChunk(distream);
-                    parse_tIME_chunk(chunk);
-                } else if (chunkType.equals("tRNS")) {
-                    chunk = readChunk(distream);
-                    parse_tRNS_chunk(chunk);
-                } else if (chunkType.equals("zTXt")) {
-                    chunk = readChunk(distream);
-                    parse_zTXt_chunk(chunk);
-                } else {
-                    chunk = readChunk(distream);
-                    // Output the chunk data in raw form
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    String msg = PropertyUtil.getString("PNGImageDecoder2");
+                    throw new RuntimeException(msg);
+                }
+                break; // fall through to the bottom
+            } else if (chunkType.equals("bKGD")) {
+                chunk = readChunk(distream);
+                parse_bKGD_chunk(chunk);
+            } else if (chunkType.equals("cHRM")) {
+                chunk = readChunk(distream);
+                parse_cHRM_chunk(chunk);
+            } else if (chunkType.equals("gAMA")) {
+                chunk = readChunk(distream);
+                parse_gAMA_chunk(chunk);
+            } else if (chunkType.equals("hIST")) {
+                chunk = readChunk(distream);
+                parse_hIST_chunk(chunk);
+            } else if (chunkType.equals("iCCP")) {
+                chunk = readChunk(distream);
+            } else if (chunkType.equals("pHYs")) {
+                chunk = readChunk(distream);
+                parse_pHYs_chunk(chunk);
+            } else if (chunkType.equals("sBIT")) {
+                chunk = readChunk(distream);
+                parse_sBIT_chunk(chunk);
+            } else if (chunkType.equals("sRGB")) {
+                chunk = readChunk(distream);
+                parse_sRGB_chunk(chunk);
+            } else if (chunkType.equals("tEXt")) {
+                chunk = readChunk(distream);
+                parse_tEXt_chunk(chunk);
+            } else if (chunkType.equals("tIME")) {
+                chunk = readChunk(distream);
+                parse_tIME_chunk(chunk);
+            } else if (chunkType.equals("tRNS")) {
+                chunk = readChunk(distream);
+                parse_tRNS_chunk(chunk);
+            } else if (chunkType.equals("zTXt")) {
+                chunk = readChunk(distream);
+                parse_zTXt_chunk(chunk);
+            } else {
+                chunk = readChunk(distream);
+                // Output the chunk data in raw form
 
-                    String type = chunk.getTypeString();
-                    byte[] data = chunk.getData();
-                    if (encodeParam != null) {
-                        encodeParam.addPrivateChunk(type, data);
-                    }
-                    if (emitProperties) {
-                        String key = "chunk_" + chunkIndex++ + ':' + type;
-                        properties.put(key.toLowerCase(), data);
-                    }
+                String type = chunk.getTypeString();
+                byte[] data = chunk.getData();
+                if (encodeParam != null) {
+                    encodeParam.addPrivateChunk(type, data);
+                }
+                if (emitProperties) {
+                    String key = "chunk_" + chunkIndex++ + ':' + type;
+                    properties.put(key.toLowerCase(Locale.getDefault()), data);
                 }
-            } catch (Exception e) {
-                e.printStackTrace();
-                String msg = PropertyUtil.getString("PNGImageDecoder2");
-                throw new RuntimeException(msg);
             }
         } while (true);
 
@@ -594,7 +586,7 @@ public class PNGRed extends AbstractRed
             encodeParam.setBitDepth(bitDepth);
         }
         if (emitProperties) {
-            properties.put("bit_depth", new Integer(bitDepth));
+            properties.put("bit_depth", bitDepth);
         }
 
         if (performGammaCorrection) {
@@ -604,7 +596,7 @@ public class PNGRed extends AbstractRed
                 encodeParam.setGamma(gamma);
             }
             if (emitProperties) {
-                properties.put("gamma", new Float(gamma));
+                properties.put("gamma", gamma);
             }
         }
 
@@ -732,7 +724,7 @@ public class PNGRed extends AbstractRed
             textArray[2 * i + 1] = val;
             if (emitProperties) {
                 String uniqueKey = "text_" + i + ':' + key;
-                properties.put(uniqueKey.toLowerCase(), val);
+                properties.put(uniqueKey.toLowerCase(Locale.getDefault()), val);
             }
         }
         if (encodeParam != null) {
@@ -749,7 +741,7 @@ public class PNGRed extends AbstractRed
             ztextArray[2 * i + 1] = val;
             if (emitProperties) {
                 String uniqueKey = "ztext_" + i + ':' + key;
-                properties.put(uniqueKey.toLowerCase(), val);
+                properties.put(uniqueKey.toLowerCase(Locale.getDefault()), val);
             }
         }
         if (encodeParam != null) {
@@ -1091,14 +1083,14 @@ public class PNGRed extends AbstractRed
             encodeParam.setChromaticity(chromaticity);
         }
         if (emitProperties) {
-            properties.put("white_point_x", new Float(chromaticity[0]));
-            properties.put("white_point_y", new Float(chromaticity[1]));
-            properties.put("red_x", new Float(chromaticity[2]));
-            properties.put("red_y", new Float(chromaticity[3]));
-            properties.put("green_x", new Float(chromaticity[4]));
-            properties.put("green_y", new Float(chromaticity[5]));
-            properties.put("blue_x", new Float(chromaticity[6]));
-            properties.put("blue_y", new Float(chromaticity[7]));
+            properties.put("white_point_x", chromaticity[0]);
+            properties.put("white_point_y", chromaticity[1]);
+            properties.put("red_x", chromaticity[2]);
+            properties.put("red_y", chromaticity[3]);
+            properties.put("green_x", chromaticity[4]);
+            properties.put("green_y", chromaticity[5]);
+            properties.put("blue_x", chromaticity[6]);
+            properties.put("blue_y", chromaticity[7]);
         }
     }
 
@@ -1116,7 +1108,7 @@ public class PNGRed extends AbstractRed
             encodeParam.setGamma(fileGamma * exp);
         }
         if (emitProperties) {
-            properties.put("gamma", new Float(fileGamma * exp));
+            properties.put("gamma", fileGamma * exp);
         }
     }
 
@@ -1137,16 +1129,6 @@ public class PNGRed extends AbstractRed
         }
     }
 
-    private void parse_iCCP_chunk(PNGChunk chunk) {
-        String name = "";
-        byte b;
-
-        int textIndex = 0;
-        while ((b = chunk.getByte(textIndex++)) != 0) {
-            name += (char)b;
-        }
-    }
-
     private void parse_pHYs_chunk(PNGChunk chunk) {
         int xPixelsPerUnit = chunk.getInt4(0);
         int yPixelsPerUnit = chunk.getInt4(4);
@@ -1158,10 +1140,10 @@ public class PNGRed extends AbstractRed
                                              unitSpecifier);
         }
         if (emitProperties) {
-            properties.put("x_pixels_per_unit", new Integer(xPixelsPerUnit));
-            properties.put("y_pixels_per_unit", new Integer(yPixelsPerUnit));
+            properties.put("x_pixels_per_unit", xPixelsPerUnit);
+            properties.put("y_pixels_per_unit", yPixelsPerUnit);
             properties.put("pixel_aspect_ratio",
-                           new Float((float)xPixelsPerUnit / yPixelsPerUnit));
+                    (float) xPixelsPerUnit / yPixelsPerUnit);
             if (unitSpecifier == 1) {
                 properties.put("pixel_units", "Meters");
             } else if (unitSpecifier != 0) {
@@ -1223,15 +1205,15 @@ public class PNGRed extends AbstractRed
                 encodeParam.setChromaticity(chromaticity);
             }
             if (emitProperties) {
-                properties.put("gamma", new Float(gamma));
-                properties.put("white_point_x", new Float(chromaticity[0]));
-                properties.put("white_point_y", new Float(chromaticity[1]));
-                properties.put("red_x", new Float(chromaticity[2]));
-                properties.put("red_y", new Float(chromaticity[3]));
-                properties.put("green_x", new Float(chromaticity[4]));
-                properties.put("green_y", new Float(chromaticity[5]));
-                properties.put("blue_x", new Float(chromaticity[6]));
-                properties.put("blue_y", new Float(chromaticity[7]));
+                properties.put("gamma", gamma);
+                properties.put("white_point_x", chromaticity[0]);
+                properties.put("white_point_y", chromaticity[1]);
+                properties.put("red_x", chromaticity[2]);
+                properties.put("red_y", chromaticity[3]);
+                properties.put("green_x", chromaticity[4]);
+                properties.put("green_y", chromaticity[5]);
+                properties.put("blue_x", chromaticity[6]);
+                properties.put("blue_y", chromaticity[7]);
             }
         }
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGSuggestedPaletteEntry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGSuggestedPaletteEntry.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGSuggestedPaletteEntry.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/png/PNGSuggestedPaletteEntry.java Fri May 22 13:26:12 2015
@@ -29,6 +29,7 @@ import java.io.Serializable;
  */
 public class PNGSuggestedPaletteEntry implements Serializable {
 
+    private static final long serialVersionUID = 8718480055883536195L;
     /** The name of the entry. */
     public String name;
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDecodeParam.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDecodeParam.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDecodeParam.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDecodeParam.java Fri May 22 13:26:12 2015
@@ -72,6 +72,7 @@ import  org.apache.xmlgraphics.image.cod
  */
 public class TIFFDecodeParam implements ImageDecodeParam {
 
+    private static final long serialVersionUID = -2371665950056848358L;
     private boolean decodePaletteAsShorts;
     private Long ifdOffset;
     private boolean convertJPEGYCbCrToRGB = true;
@@ -130,7 +131,7 @@ public class TIFFDecodeParam implements
      * the directory at that offset.
      */
     public void setIFDOffset(long offset) {
-        ifdOffset = new Long(offset);
+        ifdOffset = offset;
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDirectory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDirectory.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDirectory.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFDirectory.java Fri May 22 13:26:12 2015
@@ -64,6 +64,7 @@ import org.apache.xmlgraphics.image.code
  */
 public class TIFFDirectory implements Serializable {
 
+    private static final long serialVersionUID = 2007844835460959003L;
     /** A boolean storing the endianness of the stream. */
     boolean isBigEndian;
 
@@ -240,7 +241,7 @@ public class TIFFDirectory implements Se
                 continue;
             }
 
-            fieldIndex.put(new Integer(tag), new Integer(i));
+            fieldIndex.put(tag, i);
             Object obj = null;
 
             switch (type) {
@@ -266,7 +267,7 @@ public class TIFFDirectory implements Se
 
                         // When we encountered zero, means one string has ended
                         v.add(new String(bvalues, prevIndex,
-                                         (index - prevIndex)));
+                                         (index - prevIndex), "UTF-8"));
                         prevIndex = index;
                     }
 
@@ -368,11 +369,11 @@ public class TIFFDirectory implements Se
      * or null if the tag is not present.
      */
     public TIFFField getField(int tag) {
-        Integer i = (Integer)fieldIndex.get(new Integer(tag));
+        Integer i = (Integer)fieldIndex.get(tag);
         if (i == null) {
             return null;
         } else {
-            return fields[i.intValue()];
+            return fields[i];
         }
     }
 
@@ -380,7 +381,7 @@ public class TIFFDirectory implements Se
      * Returns true if a tag appears in the directory.
      */
     public boolean isTagPresent(int tag) {
-        return fieldIndex.containsKey(new Integer(tag));
+        return fieldIndex.containsKey(tag);
     }
 
     /**
@@ -393,7 +394,7 @@ public class TIFFDirectory implements Se
         int i = 0;
 
         while (iter.hasNext()) {
-            tags[i++] = ((Integer)iter.next()).intValue();
+            tags[i++] = (Integer) iter.next();
         }
 
         return tags;
@@ -404,7 +405,7 @@ public class TIFFDirectory implements Se
      * in this directory.
      */
     public TIFFField[] getFields() {
-        return fields;
+        return fields.clone();
     }
 
     /**
@@ -414,8 +415,8 @@ public class TIFFDirectory implements Se
      * TIFF_UNDEFINED.
      */
     public byte getFieldAsByte(int tag, int index) {
-        Integer i = (Integer)fieldIndex.get(new Integer(tag));
-        byte [] b = (fields[i.intValue()]).getAsBytes();
+        Integer i = (Integer)fieldIndex.get(tag);
+        byte [] b = (fields[i]).getAsBytes();
         return b[index];
     }
 
@@ -436,8 +437,8 @@ public class TIFFDirectory implements Se
      * TIFF_SHORT, TIFF_SSHORT, TIFF_SLONG or TIFF_LONG.
      */
     public long getFieldAsLong(int tag, int index) {
-        Integer i = (Integer)fieldIndex.get(new Integer(tag));
-        return (fields[i.intValue()]).getAsLong(index);
+        Integer i = (Integer)fieldIndex.get(tag);
+        return (fields[i]).getAsLong(index);
     }
 
     /**
@@ -457,8 +458,8 @@ public class TIFFDirectory implements Se
      * TIFF_ASCII).
      */
     public float getFieldAsFloat(int tag, int index) {
-        Integer i = (Integer)fieldIndex.get(new Integer(tag));
-        return fields[i.intValue()].getAsFloat(index);
+        Integer i = (Integer)fieldIndex.get(tag);
+        return fields[i].getAsFloat(index);
     }
 
     /**
@@ -477,8 +478,8 @@ public class TIFFDirectory implements Se
      * TIFF_ASCII).
      */
     public double getFieldAsDouble(int tag, int index) {
-        Integer i = (Integer)fieldIndex.get(new Integer(tag));
-        return fields[i.intValue()].getAsDouble(index);
+        Integer i = (Integer)fieldIndex.get(tag);
+        return fields[i].getAsDouble(index);
     }
 
     /**
@@ -528,14 +529,14 @@ public class TIFFDirectory implements Se
         }
     }
 
-    private long readLong(SeekableStream stream)
-        throws IOException {
-        if (isBigEndian) {
-            return stream.readLong();
-        } else {
-            return stream.readLongLE();
-        }
-    }
+//    private long readLong(SeekableStream stream)
+//        throws IOException {
+//        if (isBigEndian) {
+//            return stream.readLong();
+//        } else {
+//            return stream.readLongLE();
+//        }
+//    }
 
     private float readFloat(SeekableStream stream)
         throws IOException {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFEncodeParam.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFEncodeParam.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFEncodeParam.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFEncodeParam.java Fri May 22 13:26:12 2015
@@ -45,6 +45,7 @@ import org.apache.xmlgraphics.image.code
  */
 public class TIFFEncodeParam implements ImageEncodeParam {
 
+    private static final long serialVersionUID = 2471949735040024055L;
     private CompressionValue compression = CompressionValue.NONE;
 
     private boolean writeTiled;
@@ -239,13 +240,16 @@ public class TIFFEncodeParam implements
      * copied by reference.
      */
     public void setExtraFields(TIFFField[] extraFields) {
-        this.extraFields = extraFields;
+        this.extraFields = extraFields.clone();
     }
 
     /**
      * Returns the value set by <code>setExtraFields()</code>.
      */
     public TIFFField[] getExtraFields() {
-        return extraFields;
+        if (extraFields == null) {
+            return new TIFFField[0];
+        }
+        return extraFields.clone();
     }
 }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java Fri May 22 13:26:12 2015
@@ -32,7 +32,6 @@ class TIFFFaxDecoder {
     private int bytePointer;
     private byte[] data;
     private int w;
-    private int h;
     private int fillOrder;
 
     // Data structures needed to store changing elements for the previous
@@ -47,7 +46,7 @@ class TIFFFaxDecoder {
     private int compression = 2;
 
     // Variables set by T4Options
-    private int uncompressedMode;
+//    private int uncompressedMode = 0;
     private int fillBits;
     private int oneD;
 
@@ -565,7 +564,7 @@ class TIFFFaxDecoder {
     public TIFFFaxDecoder(int fillOrder, int w, int h) {
         this.fillOrder = fillOrder;
         this.w = w;
-        this.h = h;
+//        this.h = h;
 
         this.bitPointer = 0;
         this.bytePointer = 0;
@@ -766,7 +765,7 @@ class TIFFFaxDecoder {
 
 
         oneD = (int)(tiffT4Options & 0x01);
-        uncompressedMode = (int)((tiffT4Options & 0x02) >> 1);
+//        uncompressedMode = (int)((tiffT4Options & 0x02) >> 1);
         fillBits = (int)((tiffT4Options & 0x04) >> 2);
 
         // The data must start with an EOL code
@@ -920,7 +919,7 @@ class TIFFFaxDecoder {
         // uncompressedMode - have written some code for this, but this
         // has not been tested due to lack of test images using this optional
 
-        uncompressedMode = (int)((tiffT6Options & 0x02) >> 1);
+//        uncompressedMode = (int)((tiffT6Options & 0x02) >> 1);
 
         // Local cached reference
         int[] cce = currChangingElems;
@@ -1204,7 +1203,7 @@ class TIFFFaxDecoder {
             entry = initBlack[current];
 
             // Get the 3 fields from the entry
-            isT = entry & 0x0001;
+//            isT = entry & 0x0001;
             bits = (entry >>> 1) & 0x000f;
             code = (entry >>> 5) & 0x07ff;
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFField.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFField.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFField.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFField.java Fri May 22 13:26:12 2015
@@ -76,6 +76,7 @@ public class TIFFField implements Compar
 
     /** Flag for 64 bit IEEE doubles. */
     public static final int TIFF_DOUBLE    = 12;
+    private static final long serialVersionUID = 207783128222415437L;
 
     /** The tag number. */
     int tag;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImage.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImage.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImage.java Fri May 22 13:26:12 2015
@@ -193,7 +193,7 @@ public class TIFFImage extends AbstractR
         // Read the specified directory.
         TIFFDirectory dir = param.getIFDOffset() == null
             ? new TIFFDirectory(stream, directory)
-            : new TIFFDirectory(stream, param.getIFDOffset().longValue(),
+            : new TIFFDirectory(stream, param.getIFDOffset(),
                               directory);
 
         // Get the number of samples per pixel



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org