You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2013/10/24 20:45:16 UTC

svn commit: r1535496 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ main/java/org/apache/commons/imaging/common/itu_t4/ ...

Author: damjan
Date: Thu Oct 24 18:45:16 2013
New Revision: 1535496

URL: http://svn.apache.org/r1535496
Log:
Propagate exceptions from close() methods instead of swallowing and/or logging them.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java Thu Oct 24 18:45:16 2013
@@ -49,7 +49,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.wbmp.WbmpImageParser;
 import org.apache.commons.imaging.formats.xbm.XbmImageParser;
 import org.apache.commons.imaging.formats.xpm.XpmImageParser;
-import org.apache.commons.imaging.util.Debug;
 
 /**
  * Provides the abstract base class for all image reading and writing
@@ -576,11 +575,7 @@ public abstract class ImageParser extend
      */
     public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
             throws ImageWriteException, IOException {
-        try {
-            os.close(); // we are obligated to close stream.
-        } catch (final Exception e) {
-            Debug.debug(e);
-        }
+        os.close(); // we are obligated to close stream.
 
         throw new ImageWriteException("This image format (" + getName()
                 + ") cannot be written.");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java Thu Oct 24 18:45:16 2013
@@ -37,7 +37,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream;
 import org.apache.commons.imaging.icc.IccProfileInfo;
 import org.apache.commons.imaging.icc.IccProfileParser;
-import org.apache.commons.imaging.util.Debug;
 
 /**
  * The primary application programming interface (API) to the Imaging library.
@@ -300,13 +299,7 @@ public abstract class Imaging implements
             return ImageFormat.UNKNOWN;
         } finally {
             if (is != null) {
-                try {
-                    is.close();
-
-                } catch (final IOException e) {
-                    Debug.debug(e);
-
-                }
+                is.close();
             }
         }
     }
@@ -1403,12 +1396,8 @@ public abstract class Imaging implements
 
             writeImage(src, os, format, params);
         } finally {
-            try {
-                if (os != null) {
-                    os.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (os != null) {
+                os.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java Thu Oct 24 18:45:16 2013
@@ -32,8 +32,11 @@ public class ZLibUtils extends BinaryFun
     public final byte[] deflate(final byte bytes[]) throws IOException {
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         final DeflaterOutputStream dos = new DeflaterOutputStream(baos);
-        dos.write(bytes);
-        dos.close();
+        try {
+            dos.write(bytes);
+        } finally {
+            dos.close();
+        }
         return baos.toByteArray();
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java Thu Oct 24 18:45:16 2013
@@ -24,8 +24,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.RandomAccessFile;
 
-import org.apache.commons.imaging.util.Debug;
-
 public class ByteSourceFile extends ByteSource {
     private final File file;
 
@@ -61,14 +59,9 @@ public class ByteSourceFile extends Byte
             return getRAFBytes(raf, start, length,
                     "Could not read value from file");
         } finally {
-            try {
-                if (raf != null) {
-                    raf.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (raf != null) {
+                raf.close();
             }
-
         }
     }
 
@@ -92,12 +85,8 @@ public class ByteSourceFile extends Byte
             }
             return baos.toByteArray();
         } finally {
-            try {
-                if (null != is) {
-                    is.close();
-                }
-            } catch (final IOException e) {
-                Debug.debug(e);
+            if (null != is) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java Thu Oct 24 18:45:16 2013
@@ -584,11 +584,12 @@ public class T4AndT6Compression {
             T4_T6_Tables.EOL.writeBits(outputStream);
             return outputStream.toByteArray();
         } finally {
-            try {
-                if (inputStream != null) {
+            if (inputStream != null) {
+                try {
                     inputStream.close();
+                } catch (final IOException ioException) {
+                    throw new ImageWriteException("I/O error", ioException);
                 }
-            } catch (final IOException ignore) {
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java Thu Oct 24 18:45:16 2013
@@ -50,7 +50,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.bmp.writers.BmpWriterRgb;
 import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
-import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
 public class BmpImageParser extends ImageParser {
@@ -506,14 +505,9 @@ public class BmpImageParser extends Imag
             // readSignature(is);
             return readBmpHeaderInfo(is, null, verbose);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 
@@ -614,11 +608,7 @@ public class BmpImageParser extends Imag
             ic = readImageContents(is, FormatCompliance.getDefault(), verbose);
         } finally {
             if (is != null) {
-                try {
-                    is.close();
-                } catch (final IOException ignore) {
-                    Debug.debug(ignore);
-                }
+                is.close();
             }
         }
 
@@ -703,11 +693,7 @@ public class BmpImageParser extends Imag
             readImageContents(is, result, verbose);
         } finally {
             if (is != null) {
-                try {
-                    is.close();
-                } catch (final IOException ignore) {
-                    Debug.debug(ignore);
-                }
+                is.close();
             }
         }
 
@@ -723,11 +709,7 @@ public class BmpImageParser extends Imag
             return getBufferedImage(is, params);
         } finally {
             if (is != null) {
-                try {
-                    is.close();
-                } catch (final IOException ignore) {
-                    Debug.debug(ignore);
-                }
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java Thu Oct 24 18:45:16 2013
@@ -41,7 +41,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream;
 import org.apache.commons.imaging.formats.pcx.PcxConstants;
 import org.apache.commons.imaging.formats.pcx.PcxImageParser;
-import org.apache.commons.imaging.util.Debug;
 
 public class DcxImageParser extends ImageParser {
     // See http://www.fileformat.info/format/pcx/egff.htm for documentation
@@ -156,12 +155,8 @@ public class DcxImageParser extends Imag
 
             return new DcxHeader(id, pages);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
-                Debug.debug(ignored);
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -199,12 +194,8 @@ public class DcxImageParser extends Imag
                         pcxSource, new HashMap<String,Object>());
                 images.add(image);
             } finally {
-                try {
-                    if (stream != null) {
-                        stream.close();
-                    }
-                } catch (final IOException ignored) {
-                    Debug.debug(ignored);
+                if (stream != null) {
+                    stream.close();
                 }
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java Thu Oct 24 18:45:16 2013
@@ -45,7 +45,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.mylzw.MyLzwDecompressor;
 import org.apache.commons.imaging.palette.Palette;
 import org.apache.commons.imaging.palette.PaletteFactory;
-import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
 public class GifImageParser extends ImageParser {
@@ -467,14 +466,9 @@ public class GifImageParser extends Imag
 
             return result;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 
@@ -1127,14 +1121,9 @@ public class GifImageParser extends Imag
             return result.get(0);
 
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Thu Oct 24 18:45:16 2013
@@ -37,7 +37,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.IImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
-import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
 public class IcnsImageParser extends ImageParser {
@@ -257,10 +256,8 @@ public class IcnsImageParser extends Ima
 
             return new IcnsContents(icnsHeader, icnsElements);
         } finally {
-            try {
+            if (is != null) {
                 is.close();
-            } catch (final Exception e) {
-                Debug.debug(e);
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java Thu Oct 24 18:45:16 2013
@@ -44,7 +44,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.formats.bmp.BmpImageParser;
 import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
-import org.apache.commons.imaging.util.Debug;
 
 public class IcoImageParser extends ImageParser {
 
@@ -577,14 +576,9 @@ public class IcoImageParser extends Imag
 
             return new ImageContents(fileHeader, fIconDatas);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java Thu Oct 24 18:45:16 2013
@@ -93,12 +93,8 @@ public class JpegUtils extends BinaryFil
             Debug.debug("" + markerCount + " markers");
 
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java Thu Oct 24 18:45:16 2013
@@ -38,7 +38,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossless;
 import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossy;
 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
-import org.apache.commons.imaging.util.Debug;
 
 /**
  * Interface for Exif write/update/remove functionality for Jpeg/JFIF images.
@@ -559,11 +558,7 @@ public class ExifRewriter extends Binary
                 }
             }
         } finally {
-            try {
-                os.close();
-            } catch (final Exception e) {
-                Debug.debug(e);
-            }
+            os.close();
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java Thu Oct 24 18:45:16 2013
@@ -310,25 +310,17 @@ public class JpegRewriter extends Binary
         return result;
     }
 
-    protected void writeSegments(OutputStream os,
+    protected void writeSegments(final OutputStream os,
             final List<? extends JFIFPiece> segments) throws IOException {
         try {
             SOI.writeTo(os);
-
+    
             for (int i = 0; i < segments.size(); i++) {
                 final JFIFPiece piece = segments.get(i);
                 piece.write(os);
             }
-            os.close();
-            os = null;
         } finally {
-            try {
-                if (os != null) {
-                    os.close();
-                }
-            } catch (final Exception e) {
-                // swallow exception; already in the context of an exception.
-            }
+            os.close();
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java Thu Oct 24 18:45:16 2013
@@ -245,11 +245,8 @@ public class PcxImageParser extends Imag
             is = byteSource.getInputStream();
             return readPcxHeader(is, false);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -368,11 +365,8 @@ public class PcxImageParser extends Imag
             skipBytes(stream, (int) toSkip);
             return read256ColorPalette(stream);
         } finally {
-            try {
-                if (stream != null) {
-                    stream.close();
-                }
-            } catch (final IOException closeException) {
+            if (stream != null) {
+                stream.close();
             }
         }
     }
@@ -532,11 +526,8 @@ public class PcxImageParser extends Imag
             final PcxHeader pcxHeader = readPcxHeader(is, isStrict);
             return readImage(pcxHeader, is, byteSource);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Thu Oct 24 18:45:16 2013
@@ -44,13 +44,13 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.formats.png.chunks.PngChunk;
-import org.apache.commons.imaging.formats.png.chunks.PngChunkIdat;
-import org.apache.commons.imaging.formats.png.chunks.PngChunkIhdr;
-import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkGama;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkIccp;
+import org.apache.commons.imaging.formats.png.chunks.PngChunkIdat;
+import org.apache.commons.imaging.formats.png.chunks.PngChunkIhdr;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkItxt;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkPhys;
+import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkText;
 import org.apache.commons.imaging.formats.png.chunks.PngChunkZtxt;
 import org.apache.commons.imaging.formats.png.chunks.PngTextChunk;
@@ -59,7 +59,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilterIndexedColor;
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilterTrueColor;
 import org.apache.commons.imaging.icc.IccProfileParser;
-import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
 public class PngImageParser extends ImageParser implements PngConstants {
@@ -131,12 +130,8 @@ public class PngImageParser extends Imag
             chunks = readChunks(is, new int[] { chunkType, }, true);
             return chunks.size() > 0;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -245,12 +240,8 @@ public class PngImageParser extends Imag
 
             return readChunks(is, chunkTypes, returnAfterFirst);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java Thu Oct 24 18:45:16 2013
@@ -39,7 +39,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.ImageBuilder;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.palette.PaletteFactory;
-import org.apache.commons.imaging.util.Debug;
 
 public class PnmImageParser extends ImageParser implements PnmConstants {
 
@@ -190,12 +189,8 @@ public class PnmImageParser extends Imag
 
             return readHeader(is);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -312,12 +307,8 @@ public class PnmImageParser extends Imag
 
             return imageBuilder.getBufferedImage();
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java Thu Oct 24 18:45:16 2013
@@ -45,7 +45,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.psd.datareaders.CompressedDataReader;
 import org.apache.commons.imaging.formats.psd.datareaders.DataReader;
 import org.apache.commons.imaging.formats.psd.datareaders.UncompressedDataReader;
-import org.apache.commons.imaging.util.Debug;
 
 public class PsdImageParser extends ImageParser {
 
@@ -88,14 +87,9 @@ public class PsdImageParser extends Imag
 
             return readHeader(is);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 
@@ -264,14 +258,9 @@ public class PsdImageParser extends Imag
             return readImageResourceBlocks(ImageResources, imageResourceIDs,
                     maxBlocksToRead);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
     }
 
@@ -341,10 +330,7 @@ public class PsdImageParser extends Imag
             notFound = true;
         } finally {
             if (notFound && is != null) {
-                try {
-                    is.close();
-                } catch (final IOException ignore) {
-                }
+                is.close();
             }
         }
         throw new ImageReadException("getInputStream: Unknown Section: "
@@ -412,14 +398,9 @@ public class PsdImageParser extends Imag
             // "Not a Valid PSD File");
 
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
         throw new ImageReadException("getInputStream: Unknown Section: "
                 + section);
@@ -435,14 +416,9 @@ public class PsdImageParser extends Imag
             final ImageContents imageContents = readImageContents(is);
             return imageContents;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
 
     }
@@ -754,14 +730,9 @@ public class PsdImageParser extends Imag
             // ImageContents imageContents = readImageContents(is);
             // return imageContents;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
-
         }
 
         return result;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java Thu Oct 24 18:45:16 2013
@@ -29,7 +29,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.IImageMetadata;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
-import org.apache.commons.imaging.util.Debug;
 
 class RgbeInfo extends BinaryFunctions {
     // #?RADIANCE
@@ -74,12 +73,8 @@ class RgbeInfo extends BinaryFunctions {
         return height;
     }
 
-    void close() {
-        try {
-            in.close();
-        } catch (final IOException e) {
-            Debug.debug(e);
-        }
+    void close() throws IOException {
+        in.close();
     }
 
     private void readDimensions() throws IOException, ImageReadException {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Thu Oct 24 18:45:16 2013
@@ -35,7 +35,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong;
-import org.apache.commons.imaging.util.Debug;
 
 public class TiffReader extends BinaryFileParser implements TiffConstants {
 
@@ -53,12 +52,8 @@ public class TiffReader extends BinaryFi
             is = byteSource.getInputStream();
             return readTiffHeader(is, formatCompliance);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -284,12 +279,8 @@ public class TiffReader extends BinaryFi
 
             return true;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java Thu Oct 24 18:45:16 2013
@@ -166,11 +166,8 @@ public class WbmpImageParser extends Ima
             is = byteSource.getInputStream();
             return readWbmpHeader(is);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -229,11 +226,8 @@ public class WbmpImageParser extends Ima
             final WbmpHeader wbmpHeader = readWbmpHeader(is);
             return readImage(wbmpHeader, is);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java Thu Oct 24 18:45:16 2013
@@ -181,11 +181,8 @@ public class XbmImageParser extends Imag
             xbmParseResult.xbmHeader = new XbmHeader(width, height, xHot, yHot);
             return xbmParseResult;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java Thu Oct 24 18:45:16 2013
@@ -50,7 +50,6 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
-import org.apache.commons.imaging.util.Debug;
 
 public class XpmImageParser extends ImageParser {
     private static Map<String, Integer> colorNames = null;
@@ -58,48 +57,46 @@ public class XpmImageParser extends Imag
     public XpmImageParser() {
     }
 
-    private synchronized static boolean loadColorNames() {
+    private synchronized static void loadColorNames() throws ImageReadException {
         if (colorNames != null) {
-            return true;
+            return;
         }
 
-        BufferedReader reader = null;
         try {
-            final InputStream rgbTxtStream = XpmImageParser.class
-                    .getResourceAsStream("rgb.txt");
+            final InputStream rgbTxtStream =
+                    XpmImageParser.class.getResourceAsStream("rgb.txt");
             if (rgbTxtStream == null) {
-                return false;
+                throw new ImageReadException("Couldn't find rgb.txt in our resources");
             }
-            reader = new BufferedReader(new InputStreamReader(rgbTxtStream,
-                    "US-ASCII"));
             final Map<String, Integer> colors = new HashMap<String, Integer>();
-            String line;
-            while ((line = reader.readLine()) != null) {
-                if (line.startsWith("!")) {
-                    continue;
-                }
-                try {
-                    final int red = Integer.parseInt(line.substring(0, 3).trim());
-                    final int green = Integer.parseInt(line.substring(4, 7).trim());
-                    final int blue = Integer.parseInt(line.substring(8, 11).trim());
-                    final String colorName = line.substring(11).trim();
-                    colors.put(colorName, 0xff000000 | (red << 16)
-                            | (green << 8) | blue);
-                } catch (final NumberFormatException nfe) {
-                }
-            }
-            colorNames = colors;
-            return true;
-        } catch (final IOException ioException) {
-            Debug.debug(ioException);
-            return false;
-        } finally {
+            BufferedReader reader = null;
             try {
+                reader = new BufferedReader(new InputStreamReader(rgbTxtStream,
+                        "US-ASCII"));
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    if (line.startsWith("!")) {
+                        continue;
+                    }
+                    try {
+                        final int red = Integer.parseInt(line.substring(0, 3).trim());
+                        final int green = Integer.parseInt(line.substring(4, 7).trim());
+                        final int blue = Integer.parseInt(line.substring(8, 11).trim());
+                        final String colorName = line.substring(11).trim();
+                        colors.put(colorName, 0xff000000 | (red << 16)
+                                | (green << 8) | blue);
+                    } catch (final NumberFormatException nfe) {
+                        throw new ImageReadException("Couldn't parse color in rgb.txt", nfe);
+                    }
+                }
+            } finally {
                 if (reader != null) {
                     reader.close();
                 }
-            } catch (final IOException ignored) {
             }
+            colorNames = colors;
+        } catch (final IOException ioException) {
+            throw new ImageReadException("Could not parse rgb.txt", ioException);
         }
     }
 
@@ -269,11 +266,8 @@ public class XpmImageParser extends Imag
             xpmParseResult.xpmHeader = parseXpmHeader(xpmParseResult.cParser);
             return xpmParseResult;
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException ignored) {
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -365,9 +359,7 @@ public class XpmImageParser extends Imag
         } else if (color.equals("None")) {
             return 0x00000000;
         } else {
-            if (!loadColorNames()) {
-                return 0x00000000;
-            }
+            loadColorNames();
             if (colorNames.containsKey(color)) {
                 return (colorNames.get(color)).intValue();
             } else {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java Thu Oct 24 18:45:16 2013
@@ -61,11 +61,8 @@ public class IccTag implements IccConsta
             // System.out.println("\t\t\t" + "itdt: " + itdt.name);
             // }
         } finally {
-            try {
-                if (bis != null) {
-                    bis.close();
-                }
-            } catch (final IOException cannotHappen) {
+            if (bis != null) {
+                bis.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java Thu Oct 24 18:45:16 2013
@@ -63,20 +63,23 @@ public class IoUtils implements ImagingC
 
             return true;
         } finally {
-            try {
-                if (srcChannel != null) {
+            IOException closeException = null;
+            if (srcChannel != null) {
+                try {
                     srcChannel.close();
+                } catch (final IOException ioException) {
+                    closeException = ioException;
                 }
-            } catch (final IOException e) {
-                Debug.debug(e);
-
             }
-            try {
-                if (dstChannel != null) {
+            if (dstChannel != null) {
+                try {
                     dstChannel.close();
+                } catch (final IOException ioException) {
+                    closeException = ioException;
                 }
-            } catch (final IOException e) {
-                Debug.debug(e);
+            }
+            if (closeException != null) {
+                throw closeException;
             }
         }
     }
@@ -103,19 +106,23 @@ public class IoUtils implements ImagingC
             bos.flush();
         } finally {
             if (close_streams) {
-                try {
-                    if (bis != null) {
+                IOException closeException = null;
+                if (bis != null) {
+                    try {
                         bis.close();
+                    } catch (final IOException ioException) {
+                        closeException = ioException;
                     }
-                } catch (final IOException e) {
-                    Debug.debug(e);
                 }
-                try {
-                    if (bos != null) {
+                if (bos != null) {
+                    try {
                         bos.close();
+                    } catch (final IOException ioException) {
+                        closeException = ioException;
                     }
-                } catch (final IOException e) {
-                    Debug.debug(e);
+                }
+                if (closeException != null) {
+                    throw closeException;
                 }
             }
         }
@@ -139,12 +146,8 @@ public class IoUtils implements ImagingC
 
             return getInputStreamBytes(is);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (final IOException e) {
-                Debug.debug(e);
+            if (is != null) {
+                is.close();
             }
         }
     }
@@ -176,12 +179,8 @@ public class IoUtils implements ImagingC
 
             return os.toByteArray();
         } finally {
-            try {
-                if (os != null) {
-                    os.close();
-                }
-            } catch (final IOException e) {
-                Debug.debug(e);
+            if (os != null) {
+                os.close();
             }
         }
     }
@@ -200,12 +199,8 @@ public class IoUtils implements ImagingC
 
             copyStreamToStream(src, stream);
         } finally {
-            try {
-                if (stream != null) {
-                    stream.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
+            if (stream != null) {
+                stream.close();
             }
         }
     }
@@ -218,13 +213,8 @@ public class IoUtils implements ImagingC
 
             putInputStreamToFile(stream, file);
         } finally {
-            try {
-                if (stream != null) {
-                    stream.close();
-                }
-            } catch (final Exception e) {
-                Debug.debug(e);
-
+            if (stream != null) {
+                stream.close();
             }
         }
     }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java Thu Oct 24 18:45:16 2013
@@ -86,10 +86,7 @@ public class ByteSourceDataTest extends 
                 }
             } finally {
                 if (is != null) {
-                    try {
-                        is.close();
-                    } catch (final IOException ignore) {
-                    }
+                    is.close();
                 }
             }
         }
@@ -124,10 +121,7 @@ public class ByteSourceDataTest extends 
                 }
             } finally {
                 if (is != null) {
-                    try {
-                        is.close();
-                    } catch (final IOException ignored) {
-                    }
+                    is.close();
                 }
             }
         }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java?rev=1535496&r1=1535495&r2=1535496&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java Thu Oct 24 18:45:16 2013
@@ -46,11 +46,7 @@ public class WriteExifMetadataExample {
             new ExifRewriter().removeExifMetadata(jpegImageFile, os);
         } finally {
             if (os != null) {
-                try {
-                    os.close();
-                } catch (final IOException e) {
-
-                }
+                os.close();
             }
         }
     }
@@ -149,11 +145,7 @@ public class WriteExifMetadataExample {
             os = null;
         } finally {
             if (os != null) {
-                try {
-                    os.close();
-                } catch (final IOException e) {
-
-                }
+                os.close();
             }
         }
     }
@@ -237,16 +229,9 @@ public class WriteExifMetadataExample {
 
             new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
                     outputSet);
-
-            os.close();
-            os = null;
         } finally {
             if (os != null) {
-                try {
-                    os.close();
-                } catch (final IOException e) {
-
-                }
+                os.close();
             }
         }
     }
@@ -311,16 +296,9 @@ public class WriteExifMetadataExample {
 
             new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
                     outputSet);
-
-            os.close();
-            os = null;
         } finally {
             if (os != null) {
-                try {
-                    os.close();
-                } catch (final IOException e) {
-
-                }
+                os.close();
             }
         }
     }



Re: svn commit: r1535496 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ main/java/org/apache/commons/imaging/common/itu_t4/ ...

Posted by Jörg Schaible <jo...@gmx.de>.
Gary Gregory wrote:

> Nice clean ups! :)

No, it's worse now!

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1535496 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ main/java/org/apache/commons/imaging/common/itu_t4/ ...

Posted by Gary Gregory <ga...@gmail.com>.
Nice clean ups! :)

G


On Thu, Oct 24, 2013 at 2:45 PM, <da...@apache.org> wrote:

> Author: damjan
> Date: Thu Oct 24 18:45:16 2013
> New Revision: 1535496
>
> URL: http://svn.apache.org/r1535496
> Log:
> Propagate exceptions from close() methods instead of swallowing and/or
> logging them.
>
>
> Modified:
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
>
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
>
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
>
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -49,7 +49,6 @@ import org.apache.commons.imaging.format
>  import org.apache.commons.imaging.formats.wbmp.WbmpImageParser;
>  import org.apache.commons.imaging.formats.xbm.XbmImageParser;
>  import org.apache.commons.imaging.formats.xpm.XpmImageParser;
> -import org.apache.commons.imaging.util.Debug;
>
>  /**
>   * Provides the abstract base class for all image reading and writing
> @@ -576,11 +575,7 @@ public abstract class ImageParser extend
>       */
>      public void writeImage(final BufferedImage src, final OutputStream
> os, final Map<String,Object> params)
>              throws ImageWriteException, IOException {
> -        try {
> -            os.close(); // we are obligated to close stream.
> -        } catch (final Exception e) {
> -            Debug.debug(e);
> -        }
> +        os.close(); // we are obligated to close stream.
>
>          throw new ImageWriteException("This image format (" + getName()
>                  + ") cannot be written.");
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
> Thu Oct 24 18:45:16 2013
> @@ -37,7 +37,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream;
>  import org.apache.commons.imaging.icc.IccProfileInfo;
>  import org.apache.commons.imaging.icc.IccProfileParser;
> -import org.apache.commons.imaging.util.Debug;
>
>  /**
>   * The primary application programming interface (API) to the Imaging
> library.
> @@ -300,13 +299,7 @@ public abstract class Imaging implements
>              return ImageFormat.UNKNOWN;
>          } finally {
>              if (is != null) {
> -                try {
> -                    is.close();
> -
> -                } catch (final IOException e) {
> -                    Debug.debug(e);
> -
> -                }
> +                is.close();
>              }
>          }
>      }
> @@ -1403,12 +1396,8 @@ public abstract class Imaging implements
>
>              writeImage(src, os, format, params);
>          } finally {
> -            try {
> -                if (os != null) {
> -                    os.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (os != null) {
> +                os.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ZLibUtils.java
> Thu Oct 24 18:45:16 2013
> @@ -32,8 +32,11 @@ public class ZLibUtils extends BinaryFun
>      public final byte[] deflate(final byte bytes[]) throws IOException {
>          final ByteArrayOutputStream baos = new ByteArrayOutputStream();
>          final DeflaterOutputStream dos = new DeflaterOutputStream(baos);
> -        dos.write(bytes);
> -        dos.close();
> +        try {
> +            dos.write(bytes);
> +        } finally {
> +            dos.close();
> +        }
>          return baos.toByteArray();
>      }
>
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
> Thu Oct 24 18:45:16 2013
> @@ -24,8 +24,6 @@ import java.io.IOException;
>  import java.io.InputStream;
>  import java.io.RandomAccessFile;
>
> -import org.apache.commons.imaging.util.Debug;
> -
>  public class ByteSourceFile extends ByteSource {
>      private final File file;
>
> @@ -61,14 +59,9 @@ public class ByteSourceFile extends Byte
>              return getRAFBytes(raf, start, length,
>                      "Could not read value from file");
>          } finally {
> -            try {
> -                if (raf != null) {
> -                    raf.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (raf != null) {
> +                raf.close();
>              }
> -
>          }
>      }
>
> @@ -92,12 +85,8 @@ public class ByteSourceFile extends Byte
>              }
>              return baos.toByteArray();
>          } finally {
> -            try {
> -                if (null != is) {
> -                    is.close();
> -                }
> -            } catch (final IOException e) {
> -                Debug.debug(e);
> +            if (null != is) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
> Thu Oct 24 18:45:16 2013
> @@ -584,11 +584,12 @@ public class T4AndT6Compression {
>              T4_T6_Tables.EOL.writeBits(outputStream);
>              return outputStream.toByteArray();
>          } finally {
> -            try {
> -                if (inputStream != null) {
> +            if (inputStream != null) {
> +                try {
>                      inputStream.close();
> +                } catch (final IOException ioException) {
> +                    throw new ImageWriteException("I/O error",
> ioException);
>                  }
> -            } catch (final IOException ignore) {
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -50,7 +50,6 @@ import org.apache.commons.imaging.format
>  import org.apache.commons.imaging.formats.bmp.writers.BmpWriterRgb;
>  import org.apache.commons.imaging.palette.PaletteFactory;
>  import org.apache.commons.imaging.palette.SimplePalette;
> -import org.apache.commons.imaging.util.Debug;
>  import org.apache.commons.imaging.util.ParamMap;
>
>  public class BmpImageParser extends ImageParser {
> @@ -506,14 +505,9 @@ public class BmpImageParser extends Imag
>              // readSignature(is);
>              return readBmpHeaderInfo(is, null, verbose);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>
> @@ -614,11 +608,7 @@ public class BmpImageParser extends Imag
>              ic = readImageContents(is, FormatCompliance.getDefault(),
> verbose);
>          } finally {
>              if (is != null) {
> -                try {
> -                    is.close();
> -                } catch (final IOException ignore) {
> -                    Debug.debug(ignore);
> -                }
> +                is.close();
>              }
>          }
>
> @@ -703,11 +693,7 @@ public class BmpImageParser extends Imag
>              readImageContents(is, result, verbose);
>          } finally {
>              if (is != null) {
> -                try {
> -                    is.close();
> -                } catch (final IOException ignore) {
> -                    Debug.debug(ignore);
> -                }
> +                is.close();
>              }
>          }
>
> @@ -723,11 +709,7 @@ public class BmpImageParser extends Imag
>              return getBufferedImage(is, params);
>          } finally {
>              if (is != null) {
> -                try {
> -                    is.close();
> -                } catch (final IOException ignore) {
> -                    Debug.debug(ignore);
> -                }
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -41,7 +41,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream;
>  import org.apache.commons.imaging.formats.pcx.PcxConstants;
>  import org.apache.commons.imaging.formats.pcx.PcxImageParser;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class DcxImageParser extends ImageParser {
>      // See http://www.fileformat.info/format/pcx/egff.htm for
> documentation
> @@ -156,12 +155,8 @@ public class DcxImageParser extends Imag
>
>              return new DcxHeader(id, pages);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> -                Debug.debug(ignored);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -199,12 +194,8 @@ public class DcxImageParser extends Imag
>                          pcxSource, new HashMap<String,Object>());
>                  images.add(image);
>              } finally {
> -                try {
> -                    if (stream != null) {
> -                        stream.close();
> -                    }
> -                } catch (final IOException ignored) {
> -                    Debug.debug(ignored);
> +                if (stream != null) {
> +                    stream.close();
>                  }
>              }
>          }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -45,7 +45,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.mylzw.MyLzwDecompressor;
>  import org.apache.commons.imaging.palette.Palette;
>  import org.apache.commons.imaging.palette.PaletteFactory;
> -import org.apache.commons.imaging.util.Debug;
>  import org.apache.commons.imaging.util.ParamMap;
>
>  public class GifImageParser extends ImageParser {
> @@ -467,14 +466,9 @@ public class GifImageParser extends Imag
>
>              return result;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>
> @@ -1127,14 +1121,9 @@ public class GifImageParser extends Imag
>              return result.get(0);
>
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>  }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -37,7 +37,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.ByteOrder;
>  import org.apache.commons.imaging.common.IImageMetadata;
>  import org.apache.commons.imaging.common.bytesource.ByteSource;
> -import org.apache.commons.imaging.util.Debug;
>  import org.apache.commons.imaging.util.ParamMap;
>
>  public class IcnsImageParser extends ImageParser {
> @@ -257,10 +256,8 @@ public class IcnsImageParser extends Ima
>
>              return new IcnsContents(icnsHeader, icnsElements);
>          } finally {
> -            try {
> +            if (is != null) {
>                  is.close();
> -            } catch (final Exception e) {
> -                Debug.debug(e);
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -44,7 +44,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.formats.bmp.BmpImageParser;
>  import org.apache.commons.imaging.palette.PaletteFactory;
>  import org.apache.commons.imaging.palette.SimplePalette;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class IcoImageParser extends ImageParser {
>
> @@ -577,14 +576,9 @@ public class IcoImageParser extends Imag
>
>              return new ImageContents(fileHeader, fIconDatas);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
> Thu Oct 24 18:45:16 2013
> @@ -93,12 +93,8 @@ public class JpegUtils extends BinaryFil
>              Debug.debug("" + markerCount + " markers");
>
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
> Thu Oct 24 18:45:16 2013
> @@ -38,7 +38,6 @@ import org.apache.commons.imaging.format
>  import
> org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossless;
>  import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossy;
>  import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
> -import org.apache.commons.imaging.util.Debug;
>
>  /**
>   * Interface for Exif write/update/remove functionality for Jpeg/JFIF
> images.
> @@ -559,11 +558,7 @@ public class ExifRewriter extends Binary
>                  }
>              }
>          } finally {
> -            try {
> -                os.close();
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> -            }
> +            os.close();
>          }
>      }
>
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
> Thu Oct 24 18:45:16 2013
> @@ -310,25 +310,17 @@ public class JpegRewriter extends Binary
>          return result;
>      }
>
> -    protected void writeSegments(OutputStream os,
> +    protected void writeSegments(final OutputStream os,
>              final List<? extends JFIFPiece> segments) throws IOException {
>          try {
>              SOI.writeTo(os);
> -
> +
>              for (int i = 0; i < segments.size(); i++) {
>                  final JFIFPiece piece = segments.get(i);
>                  piece.write(os);
>              }
> -            os.close();
> -            os = null;
>          } finally {
> -            try {
> -                if (os != null) {
> -                    os.close();
> -                }
> -            } catch (final Exception e) {
> -                // swallow exception; already in the context of an
> exception.
> -            }
> +            os.close();
>          }
>      }
>
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -245,11 +245,8 @@ public class PcxImageParser extends Imag
>              is = byteSource.getInputStream();
>              return readPcxHeader(is, false);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -368,11 +365,8 @@ public class PcxImageParser extends Imag
>              skipBytes(stream, (int) toSkip);
>              return read256ColorPalette(stream);
>          } finally {
> -            try {
> -                if (stream != null) {
> -                    stream.close();
> -                }
> -            } catch (final IOException closeException) {
> +            if (stream != null) {
> +                stream.close();
>              }
>          }
>      }
> @@ -532,11 +526,8 @@ public class PcxImageParser extends Imag
>              final PcxHeader pcxHeader = readPcxHeader(is, isStrict);
>              return readImage(pcxHeader, is, byteSource);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -44,13 +44,13 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.ImageMetadata;
>  import org.apache.commons.imaging.common.bytesource.ByteSource;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunk;
> -import org.apache.commons.imaging.formats.png.chunks.PngChunkIdat;
> -import org.apache.commons.imaging.formats.png.chunks.PngChunkIhdr;
> -import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkGama;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkIccp;
> +import org.apache.commons.imaging.formats.png.chunks.PngChunkIdat;
> +import org.apache.commons.imaging.formats.png.chunks.PngChunkIhdr;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkItxt;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkPhys;
> +import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkText;
>  import org.apache.commons.imaging.formats.png.chunks.PngChunkZtxt;
>  import org.apache.commons.imaging.formats.png.chunks.PngTextChunk;
> @@ -59,7 +59,6 @@ import org.apache.commons.imaging.format
>  import
> org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilterIndexedColor;
>  import
> org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilterTrueColor;
>  import org.apache.commons.imaging.icc.IccProfileParser;
> -import org.apache.commons.imaging.util.Debug;
>  import org.apache.commons.imaging.util.ParamMap;
>
>  public class PngImageParser extends ImageParser implements PngConstants {
> @@ -131,12 +130,8 @@ public class PngImageParser extends Imag
>              chunks = readChunks(is, new int[] { chunkType, }, true);
>              return chunks.size() > 0;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -245,12 +240,8 @@ public class PngImageParser extends Imag
>
>              return readChunks(is, chunkTypes, returnAfterFirst);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -39,7 +39,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.ImageBuilder;
>  import org.apache.commons.imaging.common.bytesource.ByteSource;
>  import org.apache.commons.imaging.palette.PaletteFactory;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class PnmImageParser extends ImageParser implements PnmConstants {
>
> @@ -190,12 +189,8 @@ public class PnmImageParser extends Imag
>
>              return readHeader(is);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -312,12 +307,8 @@ public class PnmImageParser extends Imag
>
>              return imageBuilder.getBufferedImage();
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -45,7 +45,6 @@ import org.apache.commons.imaging.format
>  import
> org.apache.commons.imaging.formats.psd.datareaders.CompressedDataReader;
>  import org.apache.commons.imaging.formats.psd.datareaders.DataReader;
>  import
> org.apache.commons.imaging.formats.psd.datareaders.UncompressedDataReader;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class PsdImageParser extends ImageParser {
>
> @@ -88,14 +87,9 @@ public class PsdImageParser extends Imag
>
>              return readHeader(is);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>
> @@ -264,14 +258,9 @@ public class PsdImageParser extends Imag
>              return readImageResourceBlocks(ImageResources,
> imageResourceIDs,
>                      maxBlocksToRead);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>      }
>
> @@ -341,10 +330,7 @@ public class PsdImageParser extends Imag
>              notFound = true;
>          } finally {
>              if (notFound && is != null) {
> -                try {
> -                    is.close();
> -                } catch (final IOException ignore) {
> -                }
> +                is.close();
>              }
>          }
>          throw new ImageReadException("getInputStream: Unknown Section: "
> @@ -412,14 +398,9 @@ public class PsdImageParser extends Imag
>              // "Not a Valid PSD File");
>
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>          throw new ImageReadException("getInputStream: Unknown Section: "
>                  + section);
> @@ -435,14 +416,9 @@ public class PsdImageParser extends Imag
>              final ImageContents imageContents = readImageContents(is);
>              return imageContents;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>
>      }
> @@ -754,14 +730,9 @@ public class PsdImageParser extends Imag
>              // ImageContents imageContents = readImageContents(is);
>              // return imageContents;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
> -
>          }
>
>          return result;
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
> Thu Oct 24 18:45:16 2013
> @@ -29,7 +29,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.IImageMetadata;
>  import org.apache.commons.imaging.common.ImageMetadata;
>  import org.apache.commons.imaging.common.bytesource.ByteSource;
> -import org.apache.commons.imaging.util.Debug;
>
>  class RgbeInfo extends BinaryFunctions {
>      // #?RADIANCE
> @@ -74,12 +73,8 @@ class RgbeInfo extends BinaryFunctions {
>          return height;
>      }
>
> -    void close() {
> -        try {
> -            in.close();
> -        } catch (final IOException e) {
> -            Debug.debug(e);
> -        }
> +    void close() throws IOException {
> +        in.close();
>      }
>
>      private void readDimensions() throws IOException, ImageReadException {
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
> Thu Oct 24 18:45:16 2013
> @@ -35,7 +35,6 @@ import org.apache.commons.imaging.format
>  import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
>  import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
>  import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class TiffReader extends BinaryFileParser implements TiffConstants
> {
>
> @@ -53,12 +52,8 @@ public class TiffReader extends BinaryFi
>              is = byteSource.getInputStream();
>              return readTiffHeader(is, formatCompliance);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -284,12 +279,8 @@ public class TiffReader extends BinaryFi
>
>              return true;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -166,11 +166,8 @@ public class WbmpImageParser extends Ima
>              is = byteSource.getInputStream();
>              return readWbmpHeader(is);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -229,11 +226,8 @@ public class WbmpImageParser extends Ima
>              final WbmpHeader wbmpHeader = readWbmpHeader(is);
>              return readImage(wbmpHeader, is);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -181,11 +181,8 @@ public class XbmImageParser extends Imag
>              xbmParseResult.xbmHeader = new XbmHeader(width, height, xHot,
> yHot);
>              return xbmParseResult;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
> Thu Oct 24 18:45:16 2013
> @@ -50,7 +50,6 @@ import org.apache.commons.imaging.common
>  import org.apache.commons.imaging.common.bytesource.ByteSource;
>  import org.apache.commons.imaging.palette.PaletteFactory;
>  import org.apache.commons.imaging.palette.SimplePalette;
> -import org.apache.commons.imaging.util.Debug;
>
>  public class XpmImageParser extends ImageParser {
>      private static Map<String, Integer> colorNames = null;
> @@ -58,48 +57,46 @@ public class XpmImageParser extends Imag
>      public XpmImageParser() {
>      }
>
> -    private synchronized static boolean loadColorNames() {
> +    private synchronized static void loadColorNames() throws
> ImageReadException {
>          if (colorNames != null) {
> -            return true;
> +            return;
>          }
>
> -        BufferedReader reader = null;
>          try {
> -            final InputStream rgbTxtStream = XpmImageParser.class
> -                    .getResourceAsStream("rgb.txt");
> +            final InputStream rgbTxtStream =
> +                    XpmImageParser.class.getResourceAsStream("rgb.txt");
>              if (rgbTxtStream == null) {
> -                return false;
> +                throw new ImageReadException("Couldn't find rgb.txt in
> our resources");
>              }
> -            reader = new BufferedReader(new
> InputStreamReader(rgbTxtStream,
> -                    "US-ASCII"));
>              final Map<String, Integer> colors = new HashMap<String,
> Integer>();
> -            String line;
> -            while ((line = reader.readLine()) != null) {
> -                if (line.startsWith("!")) {
> -                    continue;
> -                }
> -                try {
> -                    final int red = Integer.parseInt(line.substring(0,
> 3).trim());
> -                    final int green = Integer.parseInt(line.substring(4,
> 7).trim());
> -                    final int blue = Integer.parseInt(line.substring(8,
> 11).trim());
> -                    final String colorName = line.substring(11).trim();
> -                    colors.put(colorName, 0xff000000 | (red << 16)
> -                            | (green << 8) | blue);
> -                } catch (final NumberFormatException nfe) {
> -                }
> -            }
> -            colorNames = colors;
> -            return true;
> -        } catch (final IOException ioException) {
> -            Debug.debug(ioException);
> -            return false;
> -        } finally {
> +            BufferedReader reader = null;
>              try {
> +                reader = new BufferedReader(new
> InputStreamReader(rgbTxtStream,
> +                        "US-ASCII"));
> +                String line;
> +                while ((line = reader.readLine()) != null) {
> +                    if (line.startsWith("!")) {
> +                        continue;
> +                    }
> +                    try {
> +                        final int red =
> Integer.parseInt(line.substring(0, 3).trim());
> +                        final int green =
> Integer.parseInt(line.substring(4, 7).trim());
> +                        final int blue =
> Integer.parseInt(line.substring(8, 11).trim());
> +                        final String colorName =
> line.substring(11).trim();
> +                        colors.put(colorName, 0xff000000 | (red << 16)
> +                                | (green << 8) | blue);
> +                    } catch (final NumberFormatException nfe) {
> +                        throw new ImageReadException("Couldn't parse
> color in rgb.txt", nfe);
> +                    }
> +                }
> +            } finally {
>                  if (reader != null) {
>                      reader.close();
>                  }
> -            } catch (final IOException ignored) {
>              }
> +            colorNames = colors;
> +        } catch (final IOException ioException) {
> +            throw new ImageReadException("Could not parse rgb.txt",
> ioException);
>          }
>      }
>
> @@ -269,11 +266,8 @@ public class XpmImageParser extends Imag
>              xpmParseResult.xpmHeader =
> parseXpmHeader(xpmParseResult.cParser);
>              return xpmParseResult;
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException ignored) {
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -365,9 +359,7 @@ public class XpmImageParser extends Imag
>          } else if (color.equals("None")) {
>              return 0x00000000;
>          } else {
> -            if (!loadColorNames()) {
> -                return 0x00000000;
> -            }
> +            loadColorNames();
>              if (colorNames.containsKey(color)) {
>                  return (colorNames.get(color)).intValue();
>              } else {
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
> Thu Oct 24 18:45:16 2013
> @@ -61,11 +61,8 @@ public class IccTag implements IccConsta
>              // System.out.println("\t\t\t" + "itdt: " + itdt.name);
>              // }
>          } finally {
> -            try {
> -                if (bis != null) {
> -                    bis.close();
> -                }
> -            } catch (final IOException cannotHappen) {
> +            if (bis != null) {
> +                bis.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
> (original)
> +++
> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
> Thu Oct 24 18:45:16 2013
> @@ -63,20 +63,23 @@ public class IoUtils implements ImagingC
>
>              return true;
>          } finally {
> -            try {
> -                if (srcChannel != null) {
> +            IOException closeException = null;
> +            if (srcChannel != null) {
> +                try {
>                      srcChannel.close();
> +                } catch (final IOException ioException) {
> +                    closeException = ioException;
>                  }
> -            } catch (final IOException e) {
> -                Debug.debug(e);
> -
>              }
> -            try {
> -                if (dstChannel != null) {
> +            if (dstChannel != null) {
> +                try {
>                      dstChannel.close();
> +                } catch (final IOException ioException) {
> +                    closeException = ioException;
>                  }
> -            } catch (final IOException e) {
> -                Debug.debug(e);
> +            }
> +            if (closeException != null) {
> +                throw closeException;
>              }
>          }
>      }
> @@ -103,19 +106,23 @@ public class IoUtils implements ImagingC
>              bos.flush();
>          } finally {
>              if (close_streams) {
> -                try {
> -                    if (bis != null) {
> +                IOException closeException = null;
> +                if (bis != null) {
> +                    try {
>                          bis.close();
> +                    } catch (final IOException ioException) {
> +                        closeException = ioException;
>                      }
> -                } catch (final IOException e) {
> -                    Debug.debug(e);
>                  }
> -                try {
> -                    if (bos != null) {
> +                if (bos != null) {
> +                    try {
>                          bos.close();
> +                    } catch (final IOException ioException) {
> +                        closeException = ioException;
>                      }
> -                } catch (final IOException e) {
> -                    Debug.debug(e);
> +                }
> +                if (closeException != null) {
> +                    throw closeException;
>                  }
>              }
>          }
> @@ -139,12 +146,8 @@ public class IoUtils implements ImagingC
>
>              return getInputStreamBytes(is);
>          } finally {
> -            try {
> -                if (is != null) {
> -                    is.close();
> -                }
> -            } catch (final IOException e) {
> -                Debug.debug(e);
> +            if (is != null) {
> +                is.close();
>              }
>          }
>      }
> @@ -176,12 +179,8 @@ public class IoUtils implements ImagingC
>
>              return os.toByteArray();
>          } finally {
> -            try {
> -                if (os != null) {
> -                    os.close();
> -                }
> -            } catch (final IOException e) {
> -                Debug.debug(e);
> +            if (os != null) {
> +                os.close();
>              }
>          }
>      }
> @@ -200,12 +199,8 @@ public class IoUtils implements ImagingC
>
>              copyStreamToStream(src, stream);
>          } finally {
> -            try {
> -                if (stream != null) {
> -                    stream.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> +            if (stream != null) {
> +                stream.close();
>              }
>          }
>      }
> @@ -218,13 +213,8 @@ public class IoUtils implements ImagingC
>
>              putInputStreamToFile(stream, file);
>          } finally {
> -            try {
> -                if (stream != null) {
> -                    stream.close();
> -                }
> -            } catch (final Exception e) {
> -                Debug.debug(e);
> -
> +            if (stream != null) {
> +                stream.close();
>              }
>          }
>      }
>
> Modified:
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
> (original)
> +++
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
> Thu Oct 24 18:45:16 2013
> @@ -86,10 +86,7 @@ public class ByteSourceDataTest extends
>                  }
>              } finally {
>                  if (is != null) {
> -                    try {
> -                        is.close();
> -                    } catch (final IOException ignore) {
> -                    }
> +                    is.close();
>                  }
>              }
>          }
> @@ -124,10 +121,7 @@ public class ByteSourceDataTest extends
>                  }
>              } finally {
>                  if (is != null) {
> -                    try {
> -                        is.close();
> -                    } catch (final IOException ignored) {
> -                    }
> +                    is.close();
>                  }
>              }
>          }
>
> Modified:
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java?rev=1535496&r1=1535495&r2=1535496&view=diff
>
> ==============================================================================
> ---
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
> (original)
> +++
> commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
> Thu Oct 24 18:45:16 2013
> @@ -46,11 +46,7 @@ public class WriteExifMetadataExample {
>              new ExifRewriter().removeExifMetadata(jpegImageFile, os);
>          } finally {
>              if (os != null) {
> -                try {
> -                    os.close();
> -                } catch (final IOException e) {
> -
> -                }
> +                os.close();
>              }
>          }
>      }
> @@ -149,11 +145,7 @@ public class WriteExifMetadataExample {
>              os = null;
>          } finally {
>              if (os != null) {
> -                try {
> -                    os.close();
> -                } catch (final IOException e) {
> -
> -                }
> +                os.close();
>              }
>          }
>      }
> @@ -237,16 +229,9 @@ public class WriteExifMetadataExample {
>
>              new ExifRewriter().updateExifMetadataLossless(jpegImageFile,
> os,
>                      outputSet);
> -
> -            os.close();
> -            os = null;
>          } finally {
>              if (os != null) {
> -                try {
> -                    os.close();
> -                } catch (final IOException e) {
> -
> -                }
> +                os.close();
>              }
>          }
>      }
> @@ -311,16 +296,9 @@ public class WriteExifMetadataExample {
>
>              new ExifRewriter().updateExifMetadataLossless(jpegImageFile,
> os,
>                      outputSet);
> -
> -            os.close();
> -            os = null;
>          } finally {
>              if (os != null) {
> -                try {
> -                    os.close();
> -                } catch (final IOException e) {
> -
> -                }
> +                os.close();
>              }
>          }
>      }
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory