changeset 15290:08ddb16ab33e

8150154: AIOOB Exception during sequential write of TIFF images Summary: Need to reset isRescaling variable when resetting the ImageWriter. Reviewed-by: prr
author bpb
date Mon, 08 Aug 2016 11:09:19 -0700
parents 200ba67981e8
children 1457d59f0853
files src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java test/javax/imageio/plugins/shared/RepeatingWriteTest.java
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Mon Aug 08 11:40:39 2016 +0400
+++ b/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/test/javax/imageio/plugins/shared/RepeatingWriteTest.java	Mon Aug 08 11:40:39 2016 +0400
+++ b/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;