question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException: ssl_session == null

See original GitHub issue

We met a bug recently. the trace log is

java.lang.NullPointerException: ssl_session == null
	at com.android.org.conscrypt.NativeCrypto.SSL_SESSION_cipher(Native Method)
	at com.android.org.conscrypt.OpenSSLSessionImpl.getCipherSuite(OpenSSLSessionImpl.java:320)
	at okhttp3.Handshake.get(Unknown Source)
	at okhttp3.internal.connection.RealConnection.connectTls(Unknown Source)
	at okhttp3.internal.connection.RealConnection.establishProtocol(Unknown Source)
	at okhttp3.internal.connection.RealConnection.buildConnection(Unknown Source)
	at okhttp3.internal.connection.RealConnection.connect(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.findConnection(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(Unknown Source)
	at okhttp3.internal.connection.StreamAllocation.newStream(Unknown Source)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
	at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown Source)
	at okhttp3.RealCall.access$100(Unknown Source)
	at okhttp3.RealCall$AsyncCall.execute(Unknown Source)
	at okhttp3.internal.NamedRunnable.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
	at java.lang.Thread.run(Thread.java:818)

What’s more, the phone model is m5 and M611D,system version is Android 6.0 . We think it is a rare problem when tls connect stage. It is great thing when you fixed it! Thanks ~

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
yschimkecommented, Dec 1, 2017

@swankjesse I think it’s a Google Conscrypt bug. Happened on the conscrypt branch, I reported it and there is a fix that should make 1.0.

Happens when you try to use the Session after the remote side closes it. We may want to consider catching this NPE in okhttp, rethrowing as IOException.

https://github.com/google/conscrypt/pull/381/files

6reactions
autofocuscommented, Aug 6, 2018

i met same bug recently. @swankjesse said it is a Google Conscrypt bug, i follow @yschimke’s guide,wrote a class NetExceptionHandlerInterceptor,then i add NetExceptionHandlerInterceptor to okhttpClient’s NetworkInterceptor,so it handle all Exception and rethrowing as IOException,i think this method can resolve the problem.

public class NetExceptionHandlerInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        try {
            return chain.proceed(chain.request());
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
    }
}

//add  NetExceptionHandlerInterceptor to OkHttpClient.Builder.
 OkHttpClient.Builder builder = new OkHttpClient
                .Builder();
 builder.addNetworkInterceptor(new NetExceptionHandlerInterceptor());
Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException in SSL handshake · Issue #362 - GitHub
I've never worked on this code so correct me if I'm wrong but why would handshakeSession return null unless the state is STATE_HANDSHAKE_STARTED ......
Read more >
ssl - null pointer in java NIO SSO processor - Stack Overflow
Chasing down an issue where gitblit has occassional 1 minute timeouts, and finding this in the log. Not sure if related, or not.......
Read more >
javax.net.ssl.SSLSession#getPeerCertificates
Returns the X509Certificate for the server this session is connected to. The certificate may be null. * * @param sslSession SSL session connected...
Read more >
NullPointerException (Java Platform SE 8 ) - Oracle Help Center
Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of...
Read more >
javax.net.ssl.SSLSession.isValid java code examples | Tabnine
Returns the principal identifying the peer during the handshake. invalidate. Invalidates this session. No new connections can be created, but any existing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found