Datagram socket leak (original) (raw)

Michael McMahon michael.x.mcmahon at oracle.com
Fri Sep 9 06:26:15 PDT 2011


Alan,

It didn't occur to me to use that new multi-catch construct.

I've actually just committed the previous version. But, I think this is clearer so I'd like to make this change under a new CR.

On 09/09/11 14:08, Alan Bateman wrote:

Michael McMahon wrote:

Yes, the regression tests picked that up as well. Well spotted.

http://cr.openjdk.java.net/~michaelm/7085981/webrev.5/ DatagramSocket looks okay to me. An alternative might be: try { : } catch (SocketException | IllegalArgumentException | SecurityException e) { close(); throw e; } As Socket.close can throw an IOException then maybe you could use the suppressed exception feature, ie: try { : } catch (SocketException | IllegalArgumentException | SecurityException e) { try { close(); } catch (IOException ce) { e.addSuppressed(ce); } throw e; } In passing, I notice in Socket L423 that it checks if address is null but at L416 it throws NPE if null. -Alan.



More information about the net-dev mailing list