Author: dehort
Date: 2012-06-05 17:37:52 -0400 (Tue, 05 Jun 2012)
New Revision: 2039
Modified:
branches/JBOSSWEB_2_1_10_GA_JBPAPP_9261/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
Log:
Applying potential fix for a memory leak when using SSL and the java security manager
[JBPAPP-9261]
Modified:
branches/JBOSSWEB_2_1_10_GA_JBPAPP_9261/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
---
branches/JBOSSWEB_2_1_10_GA_JBPAPP_9261/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2012-06-05
20:53:01 UTC (rev 2038)
+++
branches/JBOSSWEB_2_1_10_GA_JBPAPP_9261/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2012-06-05
21:37:52 UTC (rev 2039)
@@ -23,6 +23,8 @@
import java.net.SocketException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
@@ -52,6 +54,8 @@
private static org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(JSSESupport.class);
+ private static final Map<SSLSession, Integer> keySizeCache =
+ new WeakHashMap<SSLSession, Integer>(10);
protected SSLSocket ssl;
protected SSLSession session;
@@ -189,7 +193,7 @@
SSLSupport.CipherData c_aux[]=ciphers;
if (session == null)
return null;
- Integer keySize = (Integer) session.getValue(KEY_SIZE_KEY);
+ Integer keySize = (Integer) keySizeCache.get(session);
if (keySize == null) {
int size = 0;
String cipherSuite = session.getCipherSuite();
@@ -200,7 +204,7 @@
}
}
keySize = new Integer(size);
- session.putValue(KEY_SIZE_KEY, keySize);
+ keySizeCache.put(session, keySize);
}
return keySize;
}