# HG changeset patch # User weijun # Date 1222826505 -28800 # Node ID 31ee39bed77f06846ef58648ac7bde83e5894f3a # Parent a1964c157e685b11561b26a2c55bbcff4b13663e 6588160: jaas krb5 client leaks OS-level UDP sockets (all platforms) Reviewed-by: jccollet, chegar diff -r a1964c157e68 -r 31ee39bed77f jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java --- a/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Fri Aug 22 18:48:00 2008 -0700 +++ b/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Wed Oct 01 10:01:45 2008 +0800 @@ -274,27 +274,31 @@ + ",Attempt =" + i + ", #bytes=" + obuf.length); } - /* - * Send the data to the kdc. - */ + try { + /* + * Send the data to the kdc. + */ kdcClient.send(obuf); - /* - * And get a response. - */ - try { - ibuf = kdcClient.receive(); - break; - } catch (SocketTimeoutException se) { - if (DEBUG) { - System.out.println ("SocketTimeOutException with " + - "attempt: " + i); + /* + * And get a response. + */ + try { + ibuf = kdcClient.receive(); + break; + } catch (SocketTimeoutException se) { + if (DEBUG) { + System.out.println ("SocketTimeOutException with " + + "attempt: " + i); + } + if (i == DEFAULT_KDC_RETRY_LIMIT) { + ibuf = null; + throw se; + } } - if (i == DEFAULT_KDC_RETRY_LIMIT) { - ibuf = null; - throw se; - } + } finally { + kdcClient.close(); } } } diff -r a1964c157e68 -r 31ee39bed77f jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java --- a/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java Fri Aug 22 18:48:00 2008 -0700 +++ b/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java Wed Oct 01 10:01:45 2008 +0800 @@ -93,4 +93,7 @@ return data; } + public void close() { + dgSocket.close(); + } }