commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1291921 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan: ./ common/ common/bytesource/ common/itu_t4/ common/mylzw/ formats/jpeg/segments/ formats/png/ formats/pnm/ formats/tiff/ formats/tiff/fieldtypes/ icc/ ...
Date Tue, 21 Feb 2012 17:07:16 GMT
Author: damjan
Date: Tue Feb 21 17:07:15 2012
New Revision: 1291921

URL: http://svn.apache.org/viewvc?rev=1291921&view=rev
Log:
Fix some bugs found by Findbugs.


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryConstant.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryFileFunctions.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryInputStream.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/bytesource/ByteSourceInputStream.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/T4AndT6Compression.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/App2Segment.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/fieldtypes/FieldTypeAscii.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccProfileParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccTag.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/IoUtils.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
Tue Feb 21 17:07:15 2012
@@ -82,7 +82,7 @@ public abstract class ImageParser extend
     public final IImageMetadata getMetadata(byte bytes[])
             throws ImageReadException, IOException
     {
-        return getMetadata(bytes);
+        return getMetadata(bytes, null);
     }
 
     public final IImageMetadata getMetadata(byte bytes[], Map params)

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryConstant.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryConstant.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryConstant.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryConstant.java
Tue Feb 21 17:07:15 2012
@@ -29,7 +29,7 @@ public class BinaryConstant implements C
     
     @Override
     public BinaryConstant clone() throws CloneNotSupportedException {
-        return new BinaryConstant(value);
+        return (BinaryConstant) super.clone();
     }
     
     @Override

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryFileFunctions.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryFileFunctions.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryFileFunctions.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryFileFunctions.java
Tue Feb 21 17:07:15 2012
@@ -761,7 +761,7 @@ public class BinaryFileFunctions impleme
         System.out.println(msg + ": '" + Integer.toBinaryString(0xff & i));
     }
 
-    public final static int CharsToQuad(char c1, char c2, char c3, char c4)
+    public final static int charsToQuad(char c1, char c2, char c3, char c4)
     {
         return (((0xff & c1) << 24) | ((0xff & c2) << 16) | ((0xff &
c3) << 8) | ((0xff & c4) << 0));
     }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryInputStream.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryInputStream.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BinaryInputStream.java
Tue Feb 21 17:07:15 2012
@@ -630,7 +630,7 @@ public class BinaryInputStream extends I
         System.out.println(msg + ": '" + Integer.toBinaryString(0xff & i));
     }
 
-    protected final static int CharsToQuad(char c1, char c2, char c3, char c4)
+    protected final static int charsToQuad(char c1, char c2, char c3, char c4)
     {
         return (((0xff & c1) << 24) | ((0xff & c2) << 16) | ((0xff &
c3) << 8) | ((0xff & c4) << 0));
     }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/bytesource/ByteSourceInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/bytesource/ByteSourceInputStream.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/bytesource/ByteSourceInputStream.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/bytesource/ByteSourceInputStream.java
Tue Feb 21 17:07:15 2012
@@ -180,7 +180,12 @@ public class ByteSourceInputStream exten
         }
 
         InputStream is = getInputStream();
-        is.skip(blockStart);
+        for (long skipped = 0; skipped < blockStart; ) {
+            long ret = is.skip(blockStart - skipped);
+            if (ret >= 0) {
+                skipped += ret;
+            }
+        }
 
         byte bytes[] = new byte[blockLength];
         int total = 0;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/T4AndT6Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/T4AndT6Compression.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/T4AndT6Compression.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/T4AndT6Compression.java
Tue Feb 21 17:07:15 2012
@@ -641,7 +641,7 @@ public class T4AndT6Compression {
         int first = 0;
         int last = entries.length - 1;
         do {
-            int middle = (first + last) / 2;
+            int middle = (first + last) >>> 2;
             if (entries[middle].value.intValue() <= value &&
                     ((middle + 1) >= entries.length || value < entries[middle + 1].value.intValue()))
{
                 return entries[middle];

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
Tue Feb 21 17:07:15 2012
@@ -133,19 +133,22 @@ public class MyLzwCompressor
 
         public final boolean equals(Object o)
         {
-            ByteArray other = (ByteArray) o;
-            if (other.hash != hash)
-                return false;
-            if (other.length != length)
-                return false;
-
-            for (int i = 0; i < length; i++)
-            {
-                if (other.bytes[i + other.start] != bytes[i + start])
+            if (o instanceof ByteArray) {
+                ByteArray other = (ByteArray) o;
+                if (other.hash != hash)
+                    return false;
+                if (other.length != length)
                     return false;
-            }
 
-            return true;
+                for (int i = 0; i < length; i++)
+                {
+                    if (other.bytes[i + other.start] != bytes[i + start])
+                        return false;
+                }
+
+                return true;
+            }
+            return false;
         }
     }
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/App2Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/App2Segment.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/App2Segment.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/App2Segment.java
Tue Feb 21 17:07:15 2012
@@ -64,6 +64,20 @@ public class App2Segment extends AppnSeg
             icc_bytes = null;
         }
     }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof App2Segment) {
+            App2Segment other = (App2Segment)obj;
+            return cur_marker == other.cur_marker;
+        }
+        return false;
+    }
+    
+    @Override
+    public int hashCode() {
+        return cur_marker;
+    }
 
     public int compareTo(App2Segment other)
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngConstants.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngConstants.java
Tue Feb 21 17:07:15 2012
@@ -17,6 +17,7 @@
 package org.apache.commons.sanselan.formats.png;
 
 import org.apache.commons.sanselan.SanselanConstants;
+import org.apache.commons.sanselan.common.BinaryFileFunctions;
 
 public interface PngConstants extends SanselanConstants
 {
@@ -46,31 +47,31 @@ public interface PngConstants extends Sa
             0x74, //
     };
 
-    public final static int IEND = PngImageParser.CharsToQuad('I', 'E', 'N',
+    public final static int IEND = BinaryFileFunctions.charsToQuad('I', 'E', 'N',
             'D');
-    public final static int IHDR = PngImageParser.CharsToQuad('I', 'H', 'D',
+    public final static int IHDR = BinaryFileFunctions.charsToQuad('I', 'H', 'D',
             'R');
-    public final static int iCCP = PngImageParser.CharsToQuad('i', 'C', 'C',
+    public final static int iCCP = BinaryFileFunctions.charsToQuad('i', 'C', 'C',
             'P');
-    public final static int tEXt = PngImageParser.CharsToQuad('t', 'E', 'X',
+    public final static int tEXt = BinaryFileFunctions.charsToQuad('t', 'E', 'X',
             't');
-    public final static int zTXt = PngImageParser.CharsToQuad('z', 'T', 'X',
+    public final static int zTXt = BinaryFileFunctions.charsToQuad('z', 'T', 'X',
             't');
-    public final static int pHYs = PngImageParser.CharsToQuad('p', 'H', 'Y',
+    public final static int pHYs = BinaryFileFunctions.charsToQuad('p', 'H', 'Y',
             's');
-    public final static int PLTE = PngImageParser.CharsToQuad('P', 'L', 'T',
+    public final static int PLTE = BinaryFileFunctions.charsToQuad('P', 'L', 'T',
             'E');
-    public final static int IDAT = PngImageParser.CharsToQuad('I', 'D', 'A',
+    public final static int IDAT = BinaryFileFunctions.charsToQuad('I', 'D', 'A',
             'T');
-    public final static int tRNS = PngImageParser.CharsToQuad('t', 'R', 'N',
+    public final static int tRNS = BinaryFileFunctions.charsToQuad('t', 'R', 'N',
             'S');
-    public final static int gAMA = PngImageParser.CharsToQuad('g', 'A', 'M',
+    public final static int gAMA = BinaryFileFunctions.charsToQuad('g', 'A', 'M',
             'A');
-    public final static int sRGB = PngImageParser.CharsToQuad('s', 'R', 'G',
+    public final static int sRGB = BinaryFileFunctions.charsToQuad('s', 'R', 'G',
             'B');
 
     // XMP chunk type.
-    public final static int iTXt = PngImageParser.CharsToQuad('i', 'T', 'X',
+    public final static int iTXt = BinaryFileFunctions.charsToQuad('i', 'T', 'X',
             't');
 
     public static final byte PNG_Signature[] = {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
Tue Feb 21 17:07:15 2012
@@ -330,7 +330,11 @@ public class PnmImageParser extends Imag
             writer = new PpmWriter(useRawbits);
 
         // make copy of params; we'll clear keys as we consume them.
-        params = new HashMap(params);
+        if (params != null) {
+            params = new HashMap(params);
+        } else {
+            params = new HashMap();
+        }
 
         // clear format key.
         if (params.containsKey(PARAM_KEY_FORMAT))

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
Tue Feb 21 17:07:15 2012
@@ -137,8 +137,14 @@ public class TiffReader extends BinaryFi
         try
         {
             is = byteSource.getInputStream();
-            if (offset > 0)
-                is.skip(offset);
+            if (offset > 0) {
+                for (long skipped = 0; skipped < offset; ) {
+                    long ret = is.skip(offset - skipped);
+                    if (ret >= 0) {
+                        skipped += ret;
+                    }
+                }
+            }
 
             List<TiffField> fields = new ArrayList<TiffField>();
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/fieldtypes/FieldTypeAscii.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/fieldtypes/FieldTypeAscii.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/fieldtypes/FieldTypeAscii.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/fieldtypes/FieldTypeAscii.java
Tue Feb 21 17:07:15 2012
@@ -91,7 +91,12 @@ public class FieldTypeAscii extends Fiel
             String[] strings = (String[])o;
             int totalLength = 0;
             for (int i = 0; i < strings.length; i++) {
-                totalLength += (strings[i].getBytes().length + 1);
+                byte[] bytes = null;
+                try {
+                    bytes = strings[i].getBytes("UTF-8");
+                } catch (UnsupportedEncodingException cannotHappen) {
+                }
+                totalLength += (bytes.length + 1);
             }
             byte[] result = new byte[totalLength];
             int position = 0;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccProfileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccProfileParser.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccProfileParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccProfileParser.java
Tue Feb 21 17:07:15 2012
@@ -370,7 +370,7 @@ public class IccProfileParser extends Bi
 
             boolean result = ((DeviceManufacturer == IEC) && (DeviceModel == sRGB));
 
-            return new Boolean(result);
+            return result;
         }
         catch (Exception e)
         {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccTag.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccTag.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccTag.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/icc/IccTag.java
Tue Feb 21 17:07:15 2012
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.util.Arrays;
 
 import org.apache.commons.sanselan.ImageReadException;
 import org.apache.commons.sanselan.common.BinaryConstants;
@@ -97,7 +98,7 @@ public class IccTag implements BinaryCon
                 }) + ")");
 
         if (data == null)
-            pw.println(prefix + "data: " + data);
+            pw.println(prefix + "data: " + Arrays.toString(data));
         else
         {
             pw.println(prefix + "data: " + data.length);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
Tue Feb 21 17:07:15 2012
@@ -173,5 +173,5 @@ class ColorSpaceSubset implements Compar
     {
         index = i;
     }
-
+    
 }
\ No newline at end of file

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
Tue Feb 21 17:07:15 2012
@@ -61,8 +61,11 @@ public class MedianCutQuantizer
 
         public boolean equals(Object o)
         {
-            ColorCount other = (ColorCount) o;
-            return other.argb == this.argb;
+            if (o instanceof ColorCount) {
+                ColorCount other = (ColorCount) o;
+                return other.argb == this.argb;
+            }
+            return false;
         }
 
     }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
Tue Feb 21 17:07:15 2012
@@ -208,7 +208,7 @@ public final class Debug
     }
 
     //    public static String newline = System.getProperty("line.separator");
-    public static String newline = "\r\n";
+    public static final String newline = "\r\n";
 
     private static void log(StringBuffer buffer, String s)
     {
@@ -517,9 +517,6 @@ public final class Debug
         debug(fClass.getName(), e);
     }
 
-    private static final SimpleDateFormat timestamp = new SimpleDateFormat(
-            "yyyy-MM-dd kk:mm:ss:SSS");
-
     public static void debug(String message, boolean value)
     {
         debug(message + " " + ((value) ? ("true") : ("false")));
@@ -662,6 +659,8 @@ public final class Debug
     {
         StringBuffer result = new StringBuffer();
 
+        final SimpleDateFormat timestamp = new SimpleDateFormat(
+                "yyyy-MM-dd kk:mm:ss:SSS");
         String datetime = timestamp.format(new Date()).toLowerCase();
 
         result.append(newline);
@@ -869,7 +868,7 @@ public final class Debug
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
         }
-        else if (value instanceof byte[])
+        else if (value instanceof double[])
         {
             double[] array = (double[]) value;
             debug(prefix, array);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/IoUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/IoUtils.java?rev=1291921&r1=1291920&r2=1291921&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/IoUtils.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/IoUtils.java
Tue Feb 21 17:07:15 2012
@@ -142,8 +142,11 @@ public class IoUtils implements Sanselan
 
         try
         {
-            if (file.getParentFile() != null)
-                file.getParentFile().mkdirs();
+            if (file.getParentFile() != null && !file.getParentFile().exists()) {
+                if (!file.getParentFile().mkdirs()) {
+                    throw new IOException("Could not create directory for file " + file);
+                }
+            }
             stream = new FileOutputStream(file);
 
             copyStreamToStream(src, stream);



Mime
View raw message