summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/javax/net
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2010-10-18 23:00:51 -0700
committerBrian Carlstrom <bdc@google.com>2010-10-19 09:27:47 -0700
commit0a480846a9798c763b088a122ab0dcd3dc3a17b6 (patch)
treef3f70803f51f39bd5b78ae6f097383f234d556f7 /luni/src/main/java/javax/net
parent4ad543f9f67feed3c4a759179abd06e365560bf3 (diff)
downloadlibcore-0a480846a9798c763b088a122ab0dcd3dc3a17b6.zip
libcore-0a480846a9798c763b088a122ab0dcd3dc3a17b6.tar.gz
libcore-0a480846a9798c763b088a122ab0dcd3dc3a17b6.tar.bz2
Remove Engine.spi memory leak by clearing after access
Also other minor code cleanup such as: - made assorted fields final - fixed lazy initialization without volatile or sync Bug: 1322442 Change-Id: I34e428dff5f07a7291d635c724111d44f2deff1c
Diffstat (limited to 'luni/src/main/java/javax/net')
-rw-r--r--luni/src/main/java/javax/net/ssl/KeyManagerFactory.java24
-rw-r--r--luni/src/main/java/javax/net/ssl/SSLContext.java4
-rw-r--r--luni/src/main/java/javax/net/ssl/TrustManagerFactory.java20
3 files changed, 26 insertions, 22 deletions
diff --git a/luni/src/main/java/javax/net/ssl/KeyManagerFactory.java b/luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
index 21b9b59..b8311d0 100644
--- a/luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
+++ b/luni/src/main/java/javax/net/ssl/KeyManagerFactory.java
@@ -37,7 +37,7 @@ public class KeyManagerFactory {
private static final String SERVICE = "KeyManagerFactory";
// Used to access common engine functionality
- private static Engine engine = new Engine(SERVICE);
+ private static final Engine ENGINE = new Engine(SERVICE);
// Store default property name
private static final String PROPERTY_NAME = "ssl.KeyManagerFactory.algorithm";
@@ -76,10 +76,10 @@ public class KeyManagerFactory {
if (algorithm == null) {
throw new NullPointerException("algorithm is null");
}
- synchronized (engine) {
- engine.getInstance(algorithm, null);
- return new KeyManagerFactory((KeyManagerFactorySpi) engine.spi, engine.provider,
- algorithm);
+ synchronized (ENGINE) {
+ ENGINE.getInstance(algorithm, null);
+ return new KeyManagerFactory((KeyManagerFactorySpi) ENGINE.getSpi(),
+ ENGINE.getProvider(), algorithm);
}
}
@@ -138,9 +138,10 @@ public class KeyManagerFactory {
if (algorithm == null) {
throw new NullPointerException("algorithm is null");
}
- synchronized (engine) {
- engine.getInstance(algorithm, provider, null);
- return new KeyManagerFactory((KeyManagerFactorySpi) engine.spi, provider, algorithm);
+ synchronized (ENGINE) {
+ ENGINE.getInstance(algorithm, provider, null);
+ return new KeyManagerFactory((KeyManagerFactorySpi) ENGINE.getSpi(), provider,
+ algorithm);
}
}
@@ -163,8 +164,8 @@ public class KeyManagerFactory {
* @param algorithm
* the key management algorithm name.
*/
- protected KeyManagerFactory(KeyManagerFactorySpi factorySpi, Provider provider, String algorithm) {
- super();
+ protected KeyManagerFactory(KeyManagerFactorySpi factorySpi, Provider provider,
+ String algorithm) {
this.provider = provider;
this.algorithm = algorithm;
this.spiImpl = factorySpi;
@@ -216,7 +217,8 @@ public class KeyManagerFactory {
* @throws InvalidAlgorithmParameterException
* if an error occurs.
*/
- public final void init(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException {
+ public final void init(ManagerFactoryParameters spec)
+ throws InvalidAlgorithmParameterException {
spiImpl.engineInit(spec);
}
diff --git a/luni/src/main/java/javax/net/ssl/SSLContext.java b/luni/src/main/java/javax/net/ssl/SSLContext.java
index 5299771..8958bf8 100644
--- a/luni/src/main/java/javax/net/ssl/SSLContext.java
+++ b/luni/src/main/java/javax/net/ssl/SSLContext.java
@@ -97,7 +97,7 @@ public class SSLContext {
}
synchronized (ENGINE) {
ENGINE.getInstance(protocol, null);
- return new SSLContext((SSLContextSpi) ENGINE.spi, ENGINE.provider, protocol);
+ return new SSLContext((SSLContextSpi) ENGINE.getSpi(), ENGINE.getProvider(), protocol);
}
}
@@ -160,7 +160,7 @@ public class SSLContext {
}
synchronized (ENGINE) {
ENGINE.getInstance(protocol, provider, null);
- return new SSLContext((SSLContextSpi) ENGINE.spi, provider, protocol);
+ return new SSLContext((SSLContextSpi) ENGINE.getSpi(), provider, protocol);
}
}
diff --git a/luni/src/main/java/javax/net/ssl/TrustManagerFactory.java b/luni/src/main/java/javax/net/ssl/TrustManagerFactory.java
index 896a486..8b4ba54 100644
--- a/luni/src/main/java/javax/net/ssl/TrustManagerFactory.java
+++ b/luni/src/main/java/javax/net/ssl/TrustManagerFactory.java
@@ -37,7 +37,7 @@ public class TrustManagerFactory {
private static final String SERVICE = "TrustManagerFactory";
// Used to access common engine functionality
- private static Engine engine = new Engine(SERVICE);
+ private static final Engine ENGINE = new Engine(SERVICE);
// Store default property name
private static final String PROPERTYNAME = "ssl.TrustManagerFactory.algorithm";
@@ -75,10 +75,10 @@ public class TrustManagerFactory {
if (algorithm == null) {
throw new NullPointerException("algorithm is null");
}
- synchronized (engine) {
- engine.getInstance(algorithm, null);
- return new TrustManagerFactory((TrustManagerFactorySpi) engine.spi, engine.provider,
- algorithm);
+ synchronized (ENGINE) {
+ ENGINE.getInstance(algorithm, null);
+ return new TrustManagerFactory((TrustManagerFactorySpi) ENGINE.getSpi(),
+ ENGINE.getProvider(), algorithm);
}
}
@@ -137,9 +137,10 @@ public class TrustManagerFactory {
if (algorithm == null) {
throw new NullPointerException("algorithm is null");
}
- synchronized (engine) {
- engine.getInstance(algorithm, provider, null);
- return new TrustManagerFactory((TrustManagerFactorySpi) engine.spi, provider, algorithm);
+ synchronized (ENGINE) {
+ ENGINE.getInstance(algorithm, provider, null);
+ return new TrustManagerFactory((TrustManagerFactorySpi) ENGINE.getSpi(), provider,
+ algorithm);
}
}
@@ -211,7 +212,8 @@ public class TrustManagerFactory {
* @throws InvalidAlgorithmParameterException
* if the initialization fails.
*/
- public final void init(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException {
+ public final void init(ManagerFactoryParameters spec)
+ throws InvalidAlgorithmParameterException {
spiImpl.engineInit(spec);
}