RFR: 8278326: Socket close is not thread safe and other cleanup

Michael McMahon michaelm at openjdk.org
Mon Jan 9 11:03:53 UTC 2023


On Mon, 9 Jan 2023 10:28:33 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/java.base/share/classes/java/net/ServerSocket.java line 98:
>> 
>>> 96:         this.impl = Objects.requireNonNull(impl);
>>> 97:     }
>>> 98: 
>> 
>> What's the reason for adding this new private constructor? I don't see what the problem with the original single arg one is. `checkPermission` could be declared to return void instead of Void though.
>
> Permission checks in constructors of non-final classes are problematic when the subclass has a finalizer. It's fixed here with the same idiom that we use in other places. The return is used by as parameter so it has to be Void.

Okay, it just seemed odd that `checkPermission` already had return type Void as if a change like this was started but not completed.

-------------

PR: https://git.openjdk.org/jdk/pull/11863


More information about the net-dev mailing list