From eda06a75eec8f8d1a7adaf8141a96f8e0bdcb433 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 29 Dec 2010 09:54:02 +0000 Subject: [PATCH] Removed static socket factories; adjusted Scheme#hashCode and Scheme#equals git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1053589 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/conn/scheme/PlainSocketFactory.java | 10 ++-------- .../main/java/org/apache/http/conn/scheme/Scheme.java | 4 +--- .../org/apache/http/conn/ssl/SSLSocketFactory.java | 7 +------ .../src/test/java/org/apache/http/conn/TestScheme.java | 2 -- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java index 8325bc610..24e2900ce 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java @@ -56,21 +56,15 @@ import org.apache.http.params.HttpParams; @Immutable public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory { - /** - * The default factory. - */ - private static final PlainSocketFactory DEFAULT_FACTORY = new PlainSocketFactory(); - private final HostNameResolver nameResolver; /** - * Gets the default factory. Usually there should be no reason for creating - * multiple instances of this class. + * Gets the default factory. * * @return the default factory */ public static PlainSocketFactory getSocketFactory() { - return DEFAULT_FACTORY; + return new PlainSocketFactory(); } @Deprecated diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java index 8e31c0815..ec200404f 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java @@ -242,8 +242,7 @@ public final class Scheme { Scheme that = (Scheme) obj; return this.name.equals(that.name) && this.defaultPort == that.defaultPort - && this.layered == that.layered - && this.socketFactory.equals(that.socketFactory); + && this.layered == that.layered; } else { return false; } @@ -255,7 +254,6 @@ public final class Scheme { hash = LangUtils.hashCode(hash, this.defaultPort); hash = LangUtils.hashCode(hash, this.name); hash = LangUtils.hashCode(hash, this.layered); - hash = LangUtils.hashCode(hash, this.socketFactory); return hash; } diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java index b402f3dba..558f9a0c5 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -155,11 +155,6 @@ public class SSLSocketFactory implements LayeredSchemeSocketFactory, LayeredSock public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER = new StrictHostnameVerifier(); - /** - * The default factory using the default JVM settings for secure connections. - */ - private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory(); - /** * Gets the default factory, which uses the default JVM settings for secure * connections. @@ -167,7 +162,7 @@ public class SSLSocketFactory implements LayeredSchemeSocketFactory, LayeredSock * @return the default factory */ public static SSLSocketFactory getSocketFactory() { - return DEFAULT_FACTORY; + return new SSLSocketFactory(); } private final javax.net.ssl.SSLSocketFactory socketfactory; diff --git a/httpclient/src/test/java/org/apache/http/conn/TestScheme.java b/httpclient/src/test/java/org/apache/http/conn/TestScheme.java index 3cc168d9a..41e831b1f 100644 --- a/httpclient/src/test/java/org/apache/http/conn/TestScheme.java +++ b/httpclient/src/test/java/org/apache/http/conn/TestScheme.java @@ -47,12 +47,10 @@ public class TestScheme { Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory()); Assert.assertEquals("http", http.getName()); Assert.assertEquals(80, http.getDefaultPort()); - Assert.assertSame(PlainSocketFactory.getSocketFactory(), http.getSchemeSocketFactory()); Assert.assertFalse(http.isLayered()); Scheme https = new Scheme("https", 443, SecureSocketFactoryMockup.INSTANCE); Assert.assertEquals("https", https.getName()); Assert.assertEquals(443, https.getDefaultPort()); - Assert.assertSame(SecureSocketFactoryMockup.INSTANCE, https.getSchemeSocketFactory()); Assert.assertTrue(https.isLayered()); Scheme hTtP = new Scheme("hTtP", 80, PlainSocketFactory.getSocketFactory());