--- jsr166/src/test/tck/Collection8Test.java 2016/11/28 15:31:40 1.33 +++ jsr166/src/test/tck/Collection8Test.java 2016/11/29 05:23:31 1.37 @@ -557,15 +557,20 @@ public class Collection8Test extends JSR if (!impl.isConcurrent()) return; final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final Collection c = impl.emptyCollection(); - final long testDurationMillis = timeoutMillis(); + final long testDurationMillis + = expensiveTests ? LONG_DELAY_MS : timeoutMillis(); final AtomicBoolean done = new AtomicBoolean(false); final Object one = impl.makeElement(1); final Object two = impl.makeElement(2); + final Consumer checkSanity = x -> assertTrue(x == one || x == two); + final Consumer checkArraySanity = array -> { + // assertTrue(array.length <= 2); // duplicates are permitted + for (Object x : array) assertTrue(x == one || x == two); + }; final Object[] emptyArray = (Object[]) java.lang.reflect.Array.newInstance(one.getClass(), 0); final List> futures; final Phaser threadsStarted = new Phaser(1); // register this thread - final Consumer checkSanity = x -> assertTrue(x == one || x == two); final Runnable[] frobbers = { () -> c.forEach(checkSanity), () -> c.stream().forEach(checkSanity), @@ -581,8 +586,8 @@ public class Collection8Test extends JSR do {} while (s.tryAdvance(checkSanity)); }, () -> { for (Object x : c) checkSanity.accept(x); }, - () -> { for (Object x : c.toArray()) checkSanity.accept(x); }, - () -> { for (Object x : c.toArray(emptyArray)) checkSanity.accept(x); }, + () -> checkArraySanity.accept(c.toArray()), + () -> checkArraySanity.accept(c.toArray(emptyArray)), () -> { assertTrue(c.add(one)); assertTrue(c.contains(one));