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.

Recover gracefully from corrupted cache

See original GitHub issue

In an application using Retrofit 2.2.0 and OkHttp 3.6.0, I’m getting several crashes per day with a strange error inside OkHttp classes, which I can’t catch because I’m using async calls.

Fatal Exception: java.lang.IllegalArgumentException: unexpected url: ://example.com/api/recommend/Ans%20
       at okhttp3.Request$Builder.url(Request.java:141)
       at okhttp3.Cache$Entry.response(Cache.java:705)
       at okhttp3.Cache.get(Cache.java:210)
       at okhttp3.Cache$1.get(Cache.java:144)
       at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:70)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
       at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
       at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
       at okhttp3.RealCall.access$100(RealCall.java:33)
       at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
       at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
       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:833)

I guess what’s happening is the cache is somehow corrupted (the URL scheme is missing), and when the CacheInterceptor tries to create an HttpUrl, this exception gets thrown, and since it’s not an IOException, it’s not caught and given to my failure handler.

Shouldn’t such RuntimeExceptions be caught by RealCall and wrapped in an IOException for delivery to the failure handler?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
hugosventcommented, Mar 8, 2019

any workaround on handling this issue?

got so many crash because of Fatal Exception: java.lang.IllegalArgumentException Expected URL scheme 'http' or 'https' but no colon was found

should I just add an Interceptor which try the builder and catch the IllegalArgumentException then force it into network instead of cache by using cacheControl(FORCE_NETWORK)?

it’s so hard to reproduce it internally

3reactions
swankjessecommented, Mar 29, 2017

Yeah, we should definitely recover better when the cache breaks badly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[jira] [Created] (KUDU-3050) Recover gracefully from corrupt ...
Tim Armstrong created KUDU-3050: ----------------------------------- Summary: Recover gracefully from corrupt kerberos credential cache Key: KUDU-3050 URL: ...
Read more >
How To Recover From a Corrupt Cache
Use TIBCO Administrator to stop the BPM Node. Navigate to: CONFIG_HOME /tibcohost/Admin- ActiveMatrixEnterpriseName - ActiveMatrixServerName /data_3.2.x/nodes/ ...
Read more >
Corrupt Data Recovery - Gillware
If we cannot recover 100% of the data, we can often repair the drive, regenerating missing or corrupted data using parity blocks to...
Read more >
Gradle build fails to recover from invalid cached library ...
But it can get itself to self-corrupted state from which it can't recover. ... or even better validate libraries cache paths and recover...
Read more >
entity_get_property_info() does not gracefully recover if cache ...
If some error condition causes the entity_property_info:$langcode cache entry to be an empty array, subsequent calls to ...
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