Skip to content

NullPointerException in Cache.Entry.writeTo() #8962

@swankjesse

Description

@swankjesse

It’s crashing on the handshake!! line:

        if (url.isHttps) {
          sink.writeByte('\n'.code)
          sink.writeUtf8(handshake!!.cipherSuite.javaName).writeByte('\n'.code)
          writeCertList(sink, handshake.peerCertificates)
          writeCertList(sink, handshake.localCertificates)
          sink.writeUtf8(handshake.tlsVersion.javaName).writeByte('\n'.code)
        }

The crash looks like this:

java.lang.NullPointerException
	at okhttp3.Cache$Entry.writeTo(Cache.kt:633)
	at okhttp3.Cache.put$okhttp(Cache.kt:245)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:148)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126)

I find it a bit surprising to have an HTTPS URL with no handshake at this point.

Metadata

Metadata

Assignees

Labels

bugBug in existing code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions