Recover gracefully from corrupted cache
See original GitHub issueIn 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:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 andcatch
the IllegalArgumentException then force it into network instead of cache by usingcacheControl(FORCE_NETWORK)
?it’s so hard to reproduce it internally
Yeah, we should definitely recover better when the cache breaks badly.