8065720: (ch) AbstractInterruptibleChannel.end sets interrupted to null
Alan Bateman
Alan.Bateman at oracle.com
Sun Nov 23 19:28:59 UTC 2014
I need a reviewer for a change to AbstractInterruptibleChannel::end that
Paul Sandoz noticed when looking at this code.
AbstractInterruptibleChannel.interrupted is set to the target thread
when an operation on channel is interrupted. The end method doesn't need
to reset it but it does to avoid keeping a reference to the Thread. The
fix is trivial and a remind of the hazards of having locals with the
same name as fields.
-Alan
diff --git
a/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
b/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
---
a/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
+++
b/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
@@ -198,7 +198,7 @@
blockedOn(null);
Thread interrupted = this.interrupted;
if (interrupted != null && interrupted ==
Thread.currentThread()) {
- interrupted = null;
+ this.interrupted = null;
throw new ClosedByInterruptException();
}
if (!completed && !open)
More information about the nio-dev
mailing list