6588160: jaas krb5 client leaks OS-level UDP sockets (all platforms)
Reviewed-by: jccollet, chegar
--- 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();
}
}
}
--- 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();
+ }
}