Skip to content

Commit

Permalink
Resolved several outstanding TODOs after upgrade to HC 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ok2c committed Feb 9, 2015
1 parent 770219e commit 194eef7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
package org.apache.http.impl.client.cache;

import org.apache.http.impl.execchain.ClientExecChain;
import org.junit.Ignore;
import org.junit.Test;

public class TestHttpAsyncCacheJiraNumber1147 extends TestHttpCacheJiraNumber1147 {

Expand All @@ -40,8 +38,4 @@ protected ClientExecChain createCachingExecChain(
return new CachingHttpAsyncClientExecChain(backend, cache, config);
}

@Override @Test @Ignore // TODO: re-enable the test after HttpClient 4.3.4 release
public void testIssue1147() throws Exception {
super.testIssue1147();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.apache.http.nio.reactor.ConnectingIOReactor;
import org.apache.http.nio.reactor.IOEventDispatch;
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.ssl.SSLIOSession;
import org.apache.http.pool.ConnPoolControl;
import org.apache.http.pool.PoolStats;
import org.apache.http.protocol.HttpContext;
Expand Down Expand Up @@ -344,10 +343,6 @@ public void startRoute(
final IOSession ioSession = conn.getIOSession();
final IOSession currentSession = sf.upgrade(host, ioSession);
conn.bind(currentSession);
// TODO: to be removed (work-around for a bug in HttpCore 4.4b1)
if (currentSession instanceof SSLIOSession) {
ioSession.setBufferStatus((SSLIOSession) currentSession);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
package org.apache.http.nio.conn.ssl;

import java.io.IOException;
import java.net.URL;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Arrays;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
Expand All @@ -41,22 +39,19 @@
import javax.net.ssl.SSLSession;
import javax.security.auth.x500.X500Principal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.StrictHostnameVerifier;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
import org.apache.http.nio.conn.SchemeIOSessionStrategy;
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.ssl.SSLIOSession;
import org.apache.http.nio.reactor.ssl.SSLMode;
import org.apache.http.nio.reactor.ssl.SSLSetupHandler;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;
import org.apache.http.util.TextUtils;
Expand Down Expand Up @@ -87,39 +82,11 @@ private static String[] split(final String s) {
return s.split(" *, *");
}

//TODO: remove after upgrade to HttpCore 4.4-beta2 or newer
private static volatile PublicSuffixMatcher DEFAULT_INSTANCE;

private static PublicSuffixMatcher getDefaultPublicSuffixMatcher() {
if (DEFAULT_INSTANCE == null) {
synchronized (PublicSuffixMatcherLoader.class) {
if (DEFAULT_INSTANCE == null){
final URL url = PublicSuffixMatcherLoader.class.getResource(
"/mozilla/public-suffix-list.txt");
if (url != null) {
try {
DEFAULT_INSTANCE = PublicSuffixMatcherLoader.load(url);
} catch (IOException ex) {
// Should never happen
final Log log = LogFactory.getLog(PublicSuffixMatcherLoader.class);
if (log.isWarnEnabled()) {
log.warn("Failure loading public suffix list from default resource", ex);
}
}
} else {
DEFAULT_INSTANCE = new PublicSuffixMatcher(Arrays.asList("com"), null);
}
}
}
}
return DEFAULT_INSTANCE;
}

/**
* @since 4.1
*/
public static HostnameVerifier getDefaultHostnameVerifier() {
return new DefaultHostnameVerifier(getDefaultPublicSuffixMatcher());
return new DefaultHostnameVerifier(PublicSuffixMatcherLoader.getDefault());
}

public static SSLIOSessionStrategy getDefaultStrategy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.http.HttpHost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.impl.nio.bootstrap.HttpServer;
import org.apache.http.impl.nio.bootstrap.ServerBootstrap;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
Expand Down Expand Up @@ -98,9 +98,7 @@ public void setUp() throws Exception {
if (this.scheme.equals(ProtocolScheme.https)) {
builder.register("https", new SSLIOSessionStrategy(
SSLTestContexts.createClientSSLContext(),
// TODO: replace with the default hostname verifier
// TODO: after upgrade to HttpCore 4.4-beta2 or newer
NoopHostnameVerifier.INSTANCE));
new DefaultHostnameVerifier()));
}
final Registry<SchemeIOSessionStrategy> registry = builder.build();
final DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
Expand Down

0 comments on commit 194eef7

Please sign in to comment.