JDK 9 RFR of JDK-8144742: Instrument intermittently failing test GCDuringIteration.java

joe darcy joe.darcy at oracle.com
Fri Dec 4 18:31:54 UTC 2015


Hello,

Please review the patch below to address

     JDK-8144742: Instrument intermittently failing test 
GCDuringIteration.java

In brief, after GCDuringIteration.java was un- at ignored recently, it has 
been seen to fail intermittently in some of our testing. As the test 
uses randomness, to help the investigation GCDuringIteration.java should 
be switched over to the standard random number generator which prints 
out the seed and allows the seed to be set.

Also, the test is marked as being known to intermittently fail and for 
that reason, is bumped from tier 1 to tier 2.

Thanks,

-Joe

diff -r 8ef2bf79539c test/TEST.groups
--- a/test/TEST.groups    Thu Dec 03 13:18:51 2015 -0800
+++ b/test/TEST.groups    Fri Dec 04 10:30:58 2015 -0800
@@ -30,6 +30,7 @@
      -java/lang/ProcessHandle/TreeTest.java \
      -java/util/zip/TestLocalTime.java \
      :jdk_util \
+    -java/util/WeakHashMap/GCDuringIteration.java \
      -java/util/concurrent/Phaser/Basic.java \
      sun/nio/cs/ISO8859x.java \
      java/nio/Buffer \
@@ -40,6 +41,7 @@
      java/lang/ProcessHandle/TreeTest.java \
      java/util/zip/TestLocalTime.java \
      java/util/concurrent/Phaser/Basic.java \
+    java/util/WeakHashMap/GCDuringIteration.java \
      :jdk_io \
      :jdk_nio \
      -sun/nio/cs/ISO8859x.java \
diff -r 8ef2bf79539c test/java/util/WeakHashMap/GCDuringIteration.java
--- a/test/java/util/WeakHashMap/GCDuringIteration.java    Thu Dec 03 
13:18:51 2015 -0800
+++ b/test/java/util/WeakHashMap/GCDuringIteration.java    Fri Dec 04 
10:30:58 2015 -0800
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights 
reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights 
reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,17 @@
  /*
   * @test
   * @bug 6499848
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.RandomFactory
+ * @run main GCDuringIteration
   * @summary Check that iterators work properly in the presence of
   *          concurrent finalization and removal of elements.
- * @key randomness
+ * @key randomness intermittent
   */

  import java.util.*;
  import java.util.concurrent.CountDownLatch;
+import jdk.testlibrary.RandomFactory;

  public class GCDuringIteration {
      private static void waitForFinalizersToRun() {
@@ -65,8 +69,9 @@
          equal(map.values().iterator().next(), v);
      }

+    static final Random rnd = RandomFactory.getRandom();
+
      void checkIterator(final Iterator<Map.Entry<Foo, Integer>> it, int 
first) {
-        final Random rnd = new Random();
          for (int i = first; i >= 0; --i) {
              if (rnd.nextBoolean()) check(it.hasNext());
              equal(it.next().getValue(), i);
@@ -86,7 +91,7 @@
          final int n = 10;
          // Create array of strong refs
          final Foo[] foos = new Foo[2*n];
-        final Map<Foo,Integer> map = new 
WeakHashMap<Foo,Integer>(foos.length);
+        final Map<Foo,Integer> map = new WeakHashMap<>(foos.length);
          check(map.isEmpty());
          equal(map.size(), 0);





More information about the core-libs-dev mailing list