Adding SocketChannel toString to connection exception messages

David Lloyd david.lloyd at
Wed Jan 3 13:47:00 UTC 2018

On Fri, Dec 29, 2017 at 11:15 AM, Chris Hegarty
<chris.hegarty at> wrote:
> On 29 Dec 2017, at 00:33, Steven Schlansker <stevenschlansker at> wrote:
>> Thanks for the discussion!
>> So, it sounds like amending the message by default is going to be a non-starter -- but at least adding the information otherwise might be possible.
>> One possibility would be to add new fields to SocketException, for example an InetSocketAddress representing both the local and remote (if available).
> You would need to careful to not disclose resolved addresses to untrusted code. SocketException, since a subtype of IOException, can wind up in many places.
> Would you be proposing to add these new fields to the serial-form of SocketException? What behaviour do you envisage for deserializing instances from previous releases? This will have an impact of any potential API.

This is an advantage to a setter-only message supplement method: if
the supplementary field is set, the writeReplace method can swap it
for a new instance with the combined message.


More information about the core-libs-dev mailing list