changeset 21612:1f01e1f74f96

8027712: DistinctOpTest fails for unordered test Reviewed-by: henryjen, alanb
author psandoz
date Tue, 05 Nov 2013 12:08:12 +0100
parents 34085733bead
children 19a42489efef
files jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Mon Nov 04 15:48:08 2013 -0800
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Tue Nov 05 12:08:12 2013 +0100
@@ -54,10 +54,14 @@
         // These tests should short-circuit, otherwise will fail with a time-out
         // or an OOME
 
-        Integer one = Stream.iterate(1, i -> i + 1).unordered().parallel().distinct().findAny().get();
-        assertEquals(one.intValue(), 1);
+        // Note that since the streams are unordered and any element is requested
+        // (a non-deterministic process) the only assertion that can be made is
+        // that an element should be found
 
-        Optional<Integer> oi = ThreadLocalRandom.current().ints().boxed().parallel().distinct().findAny();
+        Optional<Integer> oi = Stream.iterate(1, i -> i + 1).unordered().parallel().distinct().findAny();
+        assertTrue(oi.isPresent());
+
+        oi = ThreadLocalRandom.current().ints().boxed().parallel().distinct().findAny();
         assertTrue(oi.isPresent());
     }