okhttp: IllegalArgumentException reading Cache Entry

We see infrequent crashes (only reports for a fraction of users, could not reproduce locally) that seem to happen when okhttp loads a cached response:

Fatal Exception: java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no colon was found
       at okhttp3.HttpUrl$Builder.parse(HttpUrl.java:1325)
       at okhttp3.HttpUrl.get(HttpUrl.java:916)
       at okhttp3.Request$Builder.url(Request.java:165)
       at okhttp3.Cache$Entry.response(Cache.java:702)
       at okhttp3.Cache.get(Cache.java:211)
       at okhttp3.Cache$1.get(Cache.java:145)
       at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:54)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at // some Interceptor that simply adds a "User-Agent" header
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
       at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
       at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)

While reading the changelog I noticed:

Fix: Don’t corrupt the response cache when a 304 (Not Modified) response overrides the stored “Content-Encoding” header.

could this be related to a corrupted cache? If yes do we need to wipe the cache or will that recover by itself?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Yeah, that’ll work. Sigh.