diff --git a/src/share/classes/sun/nio/ch/NativeThreadSet.java b/src/share/classes/sun/nio/ch/NativeThreadSet.java index b4ddbbb71ac92cd229a6550b06e17ebfe3edb5a7..51eabbcaf231b7fdf82a1b3f8b2cf82cbbd72644 100644 --- a/src/share/classes/sun/nio/ch/NativeThreadSet.java +++ b/src/share/classes/sun/nio/ch/NativeThreadSet.java @@ -96,11 +96,16 @@ class NativeThreadSet { break; } waitingToEmpty = true; + boolean interrupted = false; while (used > 0) { try { wait(); - } catch (InterruptedException ignore) { } + } catch (InterruptedException e) { + interrupted = true; + } } + if (interrupted) + Thread.currentThread().interrupt(); } } } diff --git a/test/java/nio/channels/FileChannel/ClosedByInterrupt.java b/test/java/nio/channels/FileChannel/ClosedByInterrupt.java index 24e2119d4ccf4b9413e21b09411e1f88cc2983b4..26c3d89789adebba2735a5402f000aff4ccc24f3 100644 --- a/test/java/nio/channels/FileChannel/ClosedByInterrupt.java +++ b/test/java/nio/channels/FileChannel/ClosedByInterrupt.java @@ -52,13 +52,16 @@ public class ClosedByInterrupt { fc.write(bb); } - // test with 1-8 concurrent threads - for (int i=1; i<=8; i++) { + // test with 1-16 concurrent threads + for (int i=1; i<=16; i++) { System.out.format("%d thread(s)%n", i); test(f, i); if (failed) break; } + + if (failed) + throw new RuntimeException("Test failed"); } /** @@ -132,12 +135,14 @@ public class ClosedByInterrupt { // give the interruptible thread a chance try { Thread.sleep(rand.nextInt(50)); - } catch (InterruptedException ignore) { } + } catch (InterruptedException e) { + unexpected(e); + } } } } catch (ClosedByInterruptException e) { if (interruptible) { - if (Thread.currentThread().isInterrupted()) { + if (Thread.interrupted()) { expected(e + " thrown and interrupt status set"); } else { unexpected(e + " thrown but interrupt status not set"); @@ -158,7 +163,7 @@ public class ClosedByInterrupt { } static void expected(Exception e) { - System.out.format("%s (not expected)%n", e); + System.out.format("%s (expected)%n", e); } static void expected(String msg) {