changeset 14779:cb6a4c305a0c

8144742: Instrument intermittently failing test GCDuringIteration.java Reviewed-by: rriggs, martin
author darcy
date Fri, 04 Dec 2015 11:01:53 -0800
parents fba3e5b0ba74
children 3c3a5343044c
files test/TEST.groups test/java/util/WeakHashMap/GCDuringIteration.java
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/TEST.groups	Thu Dec 03 17:44:18 2015 -0800
+++ b/test/TEST.groups	Fri Dec 04 11:01:53 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 \
--- a/test/java/util/WeakHashMap/GCDuringIteration.java	Thu Dec 03 17:44:18 2015 -0800
+++ b/test/java/util/WeakHashMap/GCDuringIteration.java	Fri Dec 04 11:01:53 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);