8224024: java/util/concurrent/BlockingQueue/DrainToFails.java testBounded fails intermittently
authordl
Fri, 24 May 2019 08:47:39 -0700
changeset 55034 f46be958c4ac
parent 55033 c72451a9f67e
child 55035 3a30c73838f6
8224024: java/util/concurrent/BlockingQueue/DrainToFails.java testBounded fails intermittently Reviewed-by: martin
test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java
--- a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java	Fri May 24 08:43:40 2019 -0700
+++ b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java	Fri May 24 08:47:39 2019 -0700
@@ -35,6 +35,7 @@
 /*
  * @test
  * @summary Test drainTo failing due to c.add throwing
+ * @library /test/lib
  */
 
 import java.util.ArrayList;
@@ -50,9 +51,11 @@
 import java.util.concurrent.RunnableScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import jdk.test.lib.Utils;
 
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class DrainToFails {
+    static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
     final int CAPACITY = 10;
     final int SMALL = 2;
 
@@ -169,7 +172,7 @@
             fail("should throw");
         } catch (IllegalStateException success) {
             for (Thread putter : putters) {
-                putter.join(2000L);
+                putter.join(LONG_DELAY_MS);
                 check(! putter.isAlive());
             }
             assertContentsInOrder(q2, 2, 3);
@@ -183,11 +186,10 @@
         }
     }
 
-    Runnable putter(final BlockingQueue q, final int elt) {
-        return new Runnable() {
-            public void run() {
-                try { q.put(elt); }
-                catch (Throwable t) { unexpected(t); }}};
+    Runnable putter(BlockingQueue q, int elt) {
+        return () -> {
+            try { q.put(elt); }
+            catch (Throwable t) { unexpected(t); }};
     }
 
     void assertContentsInOrder(Iterable it, Object... contents) {