8065720: (ch) AbstractInterruptibleChannel.end sets interrupted to null
Chris Hegarty
chris.hegarty at oracle.com
Mon Nov 24 10:36:29 UTC 2014
On 24/11/14 10:14, Paul Sandoz wrote:
>
> 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,
+1.
-Chris.
> 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)
>>
>
More information about the nio-dev
mailing list