HttpURLConnection RuntimeException

时间:2012-02-10 12:54:15

标签: android httpurlconnection

我遇到了一个奇怪的问题。我使用HttpURLConnection,当我conn.readInputStream()时,我得到RuntimeException。它并不总是可复制的,但是用户报告了这种堆栈跟踪。在开发中我从未遇到过这个问题,所以我个人不知道导致错误的原因。请提供有关此stacktracee的任何建议。

java.lang.RuntimeException: java.util.NoSuchElementException
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:692)
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:485)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:323)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.setupSecureSocket(HttpConnection.java:167)
at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:479)
at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:419)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl … veResponse(HttpURLConnectionImpl.java:1038)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:523)
at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionIm … nputStream(HttpsURLConnectionImpl.java:283)
at com.facebook.android.Util.openUrl(Util.java:245)
at com.facebook.android.Facebook.request(Facebook.java:730)
at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:313)
Caused by: java.util.NoSuchElementException
at java.util.LinkedList$LinkIterator.next(LinkedList.java:122)
at org.apache.harmony.security.x501.Name.getName0(Name.java:195)
at org.apache.harmony.security.x501.Name.getName(Name.java:135)
at javax.security.auth.x500.X500Principal.getCanonicalName(X500Principal.java:155)
at javax.security.auth.x500.X500Principal.hashCode(X500Principal.java:286)
at java.util.HashMap.get(HashMap.java:302)
at org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters.isTrustAnchor(IndexedPKIXParameters.java:113)
at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.cleanupCertChain(TrustManagerImpl.java:194)
at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:144)
at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:132)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:681)
... 12 more

2 个答案:

答案 0 :(得分:3)

此问题是由于您是从应用创建https连接,以及打开在设备上安装必要证书所需的安全连接。

答案 1 :(得分:0)

可能有点晚了,但如果你想要获得的资源不存在,就会发生这种情况。 例如,您正在尝试获取身份为500(/ user / 500)的用户,但您正在呼叫的服务器上不存在此用户。