8200116: ConstructInflaterOutput, ConstructDeflaterInput still spamming test logs
authormartin
Wed, 28 Mar 2018 21:13:55 -0700
changeset 49441 77bff7a757a4
parent 49440 396ea30afbd5
child 49442 d6d1c06becda
8200116: ConstructInflaterOutput, ConstructDeflaterInput still spamming test logs Summary: end() should always expect to be called eventually Reviewed-by: sherman, ulfzibis
test/jdk/java/util/zip/ConstructDeflaterInput.java
test/jdk/java/util/zip/ConstructInflaterOutput.java
--- a/test/jdk/java/util/zip/ConstructDeflaterInput.java	Wed Mar 28 23:56:08 2018 +0200
+++ b/test/jdk/java/util/zip/ConstructDeflaterInput.java	Wed Mar 28 21:13:55 2018 -0700
@@ -33,16 +33,15 @@
 public class ConstructDeflaterInput {
 
     static class MyDeflater extends Deflater {
-        private boolean ended = false;
-        boolean getEnded() { return ended; }
+        volatile boolean ended = false;
         public void end() {
-            fail("MyDeflater had end() called");
+            ended = true;
             super.end();
         }
     }
 
-    private static MyDeflater def = new MyDeflater();
     public static void realMain(String[] args) throws Throwable {
+        final MyDeflater def = new MyDeflater();
         ByteArrayInputStream bais = new ByteArrayInputStream(
             "hello, world".getBytes());
         DeflaterInputStream dis = null;
@@ -122,7 +121,7 @@
         //
         check(!dis.markSupported());
         check(dis.available() == 1);
-        check(!def.getEnded());
+        check(!def.ended);
         try {
             dis.reset();
             fail();
@@ -133,7 +132,7 @@
         // Check close
         //
         dis.close();
-        check(!def.getEnded());
+        check(!def.ended);
 
         try {
             dis.available();
@@ -155,7 +154,7 @@
         } catch (IOException ex) {
             pass();
         }
-
+        java.lang.ref.Reference.reachabilityFence(def);
     }
 
     //--------------------- Infrastructure ---------------------------
--- a/test/jdk/java/util/zip/ConstructInflaterOutput.java	Wed Mar 28 23:56:08 2018 +0200
+++ b/test/jdk/java/util/zip/ConstructInflaterOutput.java	Wed Mar 28 21:13:55 2018 -0700
@@ -33,17 +33,15 @@
 public class ConstructInflaterOutput {
 
     static class MyInflater extends Inflater {
-        private boolean ended = false;
-        boolean getEnded() { return ended; }
+        volatile boolean ended = false;
         public void end() {
-            fail("MyInflater had end() called");
+            ended = true;
             super.end();
         }
     }
 
-    private static MyInflater inf = new MyInflater();
-
     public static void realMain(String[] args) throws Throwable {
+        final MyInflater inf = new MyInflater();
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         InflaterOutputStream ios = null;
         byte[] b = new byte[512];
@@ -104,13 +102,13 @@
         }
 
         ios.flush();
-        check(!inf.getEnded());
+        check(!inf.ended);
         ios.flush();
-        check(!inf.getEnded());
+        check(!inf.ended);
         ios.finish();
-        check(!inf.getEnded());
+        check(!inf.ended);
         ios.close();
-        check(!inf.getEnded());
+        check(!inf.ended);
         try {
             ios.finish();
             fail();
@@ -133,6 +131,7 @@
         } catch (IOException ex) {
             pass();
         }
+        java.lang.ref.Reference.reachabilityFence(inf);
     }
 
     //--------------------- Infrastructure ---------------------------