diff options
author | Kenny Root <kroot@google.com> | 2013-07-23 20:10:12 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2013-08-13 14:30:57 -0700 |
commit | 8868084e528a9f77ebeee5b4c20416ca9939b471 (patch) | |
tree | 7122ab80ec9cf09c0cbfa64c3b4b66b0d9c36ac9 | |
parent | b975b95b02a5ae8e9e0f909c9ad39d61ba55fed4 (diff) | |
download | android_external_apache-http-8868084e528a9f77ebeee5b4c20416ca9939b471.tar.gz android_external_apache-http-8868084e528a9f77ebeee5b4c20416ca9939b471.tar.bz2 android_external_apache-http-8868084e528a9f77ebeee5b4c20416ca9939b471.zip |
Do not initialize SSLSocketFactory too early
During Zygote initialization, the class may be preloaded. However we do
not want the default instances of SSLSocketFactory initialized, so move
those into a holder class so they are only initialized when used.
(cherry picked from commit 72017834153711733905dfcf4bfe7b802062692b)
Bug: 9984058
Change-Id: Ied901aa97dbbf0f7439f317d21d4b715b5705d96
-rw-r--r-- | src/org/apache/http/conn/ssl/SSLSocketFactory.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/org/apache/http/conn/ssl/SSLSocketFactory.java b/src/org/apache/http/conn/ssl/SSLSocketFactory.java index 1be6c3a..9195b4f 100644 --- a/src/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/src/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -150,19 +150,26 @@ public class SSLSocketFactory implements LayeredSocketFactory { public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER = new StrictHostnameVerifier(); - /** - * The factory using the default JVM settings for secure connections. + + /* + * Put defaults into holder class to avoid class preloading creating an + * instance of the classes referenced. */ - private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory(); - + private static class NoPreloadHolder { + /** + * The factory using the default JVM settings for secure connections. + */ + private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory(); + } + /** * Gets an singleton instance of the SSLProtocolSocketFactory. * @return a SSLProtocolSocketFactory */ public static SSLSocketFactory getSocketFactory() { - return DEFAULT_FACTORY; + return NoPreloadHolder.DEFAULT_FACTORY; } - + private final SSLContext sslcontext; private final javax.net.ssl.SSLSocketFactory socketfactory; private final HostNameResolver nameResolver; |