8065720: (ch) AbstractInterruptibleChannel.end sets interrupted to null
Paul Sandoz
paul.sandoz at oracle.com
Mon Nov 24 10:14:48 UTC 2014
On Nov 23, 2014, at 8:28 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> I need a reviewer for a change to AbstractInterruptibleChannel::end that Paul Sandoz noticed when looking at this code.
>
Looks good,
Paul.
> 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)
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20141124/a7296004/signature-0001.asc>
More information about the nio-dev
mailing list