commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1539232 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
Date Wed, 06 Nov 2013 03:57:35 GMT
Author: damjan
Date: Wed Nov  6 03:57:34 2013
New Revision: 1539232

URL: http://svn.apache.org/r1539232
Log:
Fix some FindBugs warnings.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java?rev=1539232&r1=1539231&r2=1539232&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
Wed Nov  6 03:57:34 2013
@@ -28,6 +28,7 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSourceFile;
 import org.apache.commons.imaging.util.CachingInputStream;
 import org.apache.commons.imaging.util.Debug;
+import org.apache.commons.imaging.util.IoUtils;
 
 public class IccProfileParser extends BinaryFileParser implements IccConstants {
     public IccProfileParser() {
@@ -304,86 +305,64 @@ public class IccProfileParser extends Bi
         return null;
     }
 
-    public Boolean issRGB(final ICC_Profile icc_profile) {
-        if (icc_profile == null) {
-            return null;
-        }
-
+    public boolean issRGB(final ICC_Profile icc_profile) throws IOException {
         return issRGB(new ByteSourceArray(icc_profile.getData()));
     }
 
-    public Boolean issRGB(final byte bytes[]) {
-        if (bytes == null) {
-            return null;
-        }
-
+    public boolean issRGB(final byte bytes[]) throws IOException {
         return issRGB(new ByteSourceArray(bytes));
     }
 
-    public Boolean issRGB(final File file) {
-        if (file == null) {
-            return null;
-        }
-
+    public boolean issRGB(final File file) throws IOException {
         return issRGB(new ByteSourceFile(file));
     }
 
-    public Boolean issRGB(final ByteSource byteSource) {
-        try {
-            if (getDebug()) {
-                Debug.debug();
-            }
-
-            // setDebug(true);
-
-            // long length = byteSource.getLength();
-            //
-            // if (getDebug())
-            // Debug.debug("length: " + length);
+    public boolean issRGB(final ByteSource byteSource) throws IOException {
+        if (getDebug()) {
+            Debug.debug();
+        }
 
-            InputStream is = null;
-            try {
-                is = byteSource.getInputStream();
+        // setDebug(true);
 
-                read4Bytes("ProfileSize", is, "Not a Valid ICC Profile");
+        // long length = byteSource.getLength();
+        //
+        // if (getDebug())
+        // Debug.debug("length: " + length);
 
-                // if (length != ProfileSize)
-                // return null;
+        InputStream is = null;
+        boolean canThrow = false;
+        try {
+            is = byteSource.getInputStream();
 
-                this.skipBytes(is, 4 * 5);
+            read4Bytes("ProfileSize", is, "Not a Valid ICC Profile");
 
-                skipBytes(is, 12, "Not a Valid ICC Profile");
+            // if (length != ProfileSize)
+            // return null;
 
-                this.skipBytes(is, 4 * 3);
+            this.skipBytes(is, 4 * 5);
 
-                final int DeviceManufacturer = read4Bytes("ProfileFileSignature", is,
-                        "Not a Valid ICC Profile");
-                if (getDebug()) {
-                    printCharQuad("DeviceManufacturer", DeviceManufacturer);
-                }
+            skipBytes(is, 12, "Not a Valid ICC Profile");
 
-                final int DeviceModel = read4Bytes("DeviceModel", is,
-                        "Not a Valid ICC Profile");
-                if (getDebug()) {
-                    printCharQuad("DeviceModel", DeviceModel);
-                }
+            this.skipBytes(is, 4 * 3);
 
-                final boolean result = ((DeviceManufacturer == IEC) && (DeviceModel
== sRGB));
+            final int DeviceManufacturer = read4Bytes("ProfileFileSignature", is,
+                    "Not a Valid ICC Profile");
+            if (getDebug()) {
+                printCharQuad("DeviceManufacturer", DeviceManufacturer);
+            }
 
-                return result;
-            } finally {
-                if (is != null) {
-                    try {
-                        is.close();
-                    } catch (final IOException ignore) {
-                    }
-                }
+            final int DeviceModel = read4Bytes("DeviceModel", is,
+                    "Not a Valid ICC Profile");
+            if (getDebug()) {
+                printCharQuad("DeviceModel", DeviceModel);
             }
-        } catch (final Exception e) {
-            Debug.debug(e);
-        }
 
-        return null;
+            final boolean result = ((DeviceManufacturer == IEC) && (DeviceModel ==
sRGB));
+            canThrow = true;
+            return result;
+        } finally {
+            IoUtils.closeQuietly(canThrow, is);
+        }
     }
 
 }



Mime
View raw message