From 911dda4ee1afddd214271b07ae879315c33aeff9 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 9 Aug 2016 07:50:26 -0700 Subject: [PATCH] 8163305: Add some print instrumentation to java/nio/channels/Selector/RacyDeregister Perform more iterations on Windows, and on all platforms if the test enters the failure branch, poll for an extra period of time to determine whether it might have succeeded with a longer timeout Reviewed-by: chegar --- .../nio/channels/Selector/RacyDeregister.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/nio/channels/Selector/RacyDeregister.java b/jdk/test/java/nio/channels/Selector/RacyDeregister.java index 5a72df18107..c0b98190fab 100644 --- a/jdk/test/java/nio/channels/Selector/RacyDeregister.java +++ b/jdk/test/java/nio/channels/Selector/RacyDeregister.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -40,6 +40,11 @@ import java.nio.channels.SocketChannel; */ public class RacyDeregister { + // FIXME: numOuterLoopIterations should be reverted to the hard-coded value + // 15 when JDK-8161083 is resolved as either a bug or a non-issue. + static final int numOuterLoopIterations = + System.getProperty("os.name").startsWith("Windows") ? 150 : 15; + static boolean notified; static final Object selectorLock = new Object(); static final Object notifyLock = new Object(); @@ -77,7 +82,7 @@ public class RacyDeregister { public void run() { try { - for (int k = 0; k < 15; k++) { + for (int k = 0; k < numOuterLoopIterations; k++) { for (int i = 0; i < 10000; i++) { synchronized (notifyLock) { synchronized (selectorLock) { @@ -94,6 +99,17 @@ public class RacyDeregister { } long endTime = System.currentTimeMillis(); if (endTime - beginTime > 5000) { + for (int j = 0; j < 60; j++) { + Thread.sleep(1000); + if (notified) { + long t = + System.currentTimeMillis(); + System.out.printf + ("Notified after %d ms%n", + t - beginTime); + break; + } + } succTermination = false; // wake up main thread doing select() sel.wakeup();