Datagram socket leak

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


http://cr.openjdk.java.net/~michaelm/7088747/webrev.1/

There are no changes in the first two files, only Socket.java

- Michael.

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