On 18/12/2019 10:55, Daniel Fuchs wrote:
We already have two implementations of DatagramSocket: one is the plain
DatagramSocket, the other is the DatagramSocket adapter created by
DatagramChannel::socket.

Even without preparing for DatagramSocket reimplementation this
is a step forward in homogenizing these two implementations in
the spec.

Oh - I see DatagramChannel::socket adapter also behaves like this
and explicitly ignores the ClosedChannelException.

Is there any reason for letting connect go through if the socket
is closed? I mean - should we change the spec/behavior of
DatagramSocket (and the adapter) to throw in that case?
Changing DatagramSocket connect to throw an exception when the socket is closed would be an incompatible change so I think this is a case where the spec will just need to align with long standing behavior. The disconnect method already specifies that it is a no-op when the socket is closed so at least they will be consistent.

BTW: I think socket adaptor behavior should take a back seat in any spec discussions as its raison d'etre was to support binding and socket options. It does have to do a few ugly things in places (like catch ClosedChannelException) but this is only because it emulate legacy DatagramSocket behavior (both specified and unspecified).

-Alan.

Reply via email to