8150154: AIOOB Exception during sequential write of TIFF images
authorbpb
Mon, 08 Aug 2016 11:09:19 -0700
changeset 40429 d873154f9975
parent 40428 a7bcfb5351d7
child 40430 bebff93feeb2
8150154: AIOOB Exception during sequential write of TIFF images Summary: Need to reset isRescaling variable when resetting the ImageWriter. Reviewed-by: prr
jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java
jdk/test/javax/imageio/plugins/shared/RepeatingWriteTest.java
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Mon Aug 08 11:40:39 2016 +0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Mon Aug 08 11:09:19 2016 -0700
@@ -3622,6 +3622,8 @@
         streamMetadata = null;
         imageMetadata = null;
 
+        isRescaling = false;
+
         isWritingSequence = false;
         isWritingEmpty = false;
         isInsertingEmpty = false;
--- a/jdk/test/javax/imageio/plugins/shared/RepeatingWriteTest.java	Mon Aug 08 11:40:39 2016 +0400
+++ b/jdk/test/javax/imageio/plugins/shared/RepeatingWriteTest.java	Mon Aug 08 11:09:19 2016 -0700
@@ -25,7 +25,6 @@
  * @test
  *
  * @bug     8144991 8150154
- * @ignore  8150154
  * @author  a.stepanov
  * @summary Check if repeating image writing doesn't fail
  *          (particularly, no AIOOB occurs)
@@ -103,17 +102,18 @@
         reader.setInput(iis);
         BufferedImage img = reader.read(0);
         Color c = new Color(img.getRGB(szRef / 2, szRef / 2));
-
         int w = img.getWidth(), h = img.getHeight();
 
         if (w != szRef || h != szRef) {
             throw new ImageCheckException(fileName +
-                ": invalid image size " + w + " x " + h);
+                ": invalid image size " + w + " x " + h +
+                " expected " + szRef + " x " + szRef);
         }
 
         if (!c.equals(cRef)) {
             throw new ImageCheckException(fileName +
-                ": invalid image color " + c);
+                ": invalid image color " + c +
+                " expected " + cRef);
         }
     }
 
@@ -128,6 +128,14 @@
             return;
         }
 
+        // If JDK-8163323 is fixed this if block should be removed.
+        if (format.equals("tiff")
+            && (NAMES[i].equals("TYPE_USHORT_555_RGB")
+                 || NAMES[i].equals("TYPE_USHORT_565_RGB"))
+                && (NAMES[j].equals("TYPE_USHORT_555_RGB")
+                    || NAMES[j].equals("TYPE_USHORT_565_RGB"))) {
+            return;
+        }
 
         String f1 = "test-1-" + NAMES[i] + "." + format;
         String f2 = "test-2-" + NAMES[j] + "." + format;