2

我在多个工作人员中使用 Apache HTTP 客户端,看起来存在某种竞争条件(最后是堆栈跟踪)。我很困惑,因为谷歌搜索堆栈跟踪没有提供任何提示(还)。在 Linux 上使用 Java 1.7.0-b147 64 位。

  1. 我在这里做错了吗?
  2. 是否有已知的有效替代方案来替代 Sun 的SSLSocket?

编辑: 也许没用,但调用代码是这样的:

public String call() {
    HttpUriRequest request = new HttpGet(aUrl);
    HttpResponse response = httpClient.execute(request);
    StatusLine statusLine = response.getStatusLine();
    return EntityUtils.toString(response.getEntity());
}

其中 httpClient 共享给所有可调用对象。

堆栈跟踪:

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) 
4

1 回答 1

2

这是一个 JDK 问题。我们在运行 JDK 1.7.0_u4 时遇到了这个问题,升级到 JDK 1.7.0_u25 后问题得到解决。

于 2013-11-07T10:48:06.827 回答