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
This commit is contained in:
Oleg Kalnichevski 2010-12-29 09:54:02 +00:00
parent 18de7cda9c
commit eda06a75ee
4 changed files with 4 additions and 19 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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());