I am using Apache HTTP client in multiple workers, and it looks like there is some kind of race condition (stacktrace is at the end). I am puzzled as googling the stacktrace does not provide any hint (yet). Using Java 1.7.0-b147 64bits on Linux.
- Am I doing something wrong here?
- Are there known, efficient alternatives to Sun's implementations of
SSLSocket
?
Edit: Maybe not useful, but the calling code is like :
public String call() {
HttpUriRequest request = new HttpGet(aUrl);
HttpResponse response = httpClient.execute(request);
StatusLine statusLine = response.getStatusLine();
return EntityUtils.toString(response.getEntity());
}
in which the httpClient is shared to all callables.
Stacktrace:
java.lang.NullPointerException
at sun.security.ssl.SSLSocketImpl.getEnabledCipherSuites(SSLSocketImpl.java:2320)
at javax.net.ssl.SSLSocket.getSSLParameters(SSLSocket.java:614)
at sun.security.ssl.SSLSocketImpl.getSSLParameters(SSLSocketImpl.java:2406)
at sun.security.ssl.SSLAlgorithmConstraints.<init>(SSLAlgorithmConstraints.java:65)
at sun.security.ssl.Handshaker.init(Handshaker.java:236)
at sun.security.ssl.Handshaker.<init>(Handshaker.java:191)
at sun.security.ssl.ClientHandshaker.<init>(ClientHandshaker.java:104)
at sun.security.ssl.SSLSocketImpl.initHandshaker(SSLSocketImpl.java:1217)
at sun.security.ssl.SSLSocketImpl.doneConnect(SSLSocketImpl.java:634)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:608)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:414)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
This is a JDK issue. We had this issue when running JDK 1.7.0_u4 and it was resolved after upgrading to JDK 1.7.0_u25.