-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more context when failing to read from the cache #6260
Comments
What version of OkHttp and Okio are you including in your app? Look similar-ish to #2281 What would your suggested change be? Care to submit a PR? We don't expect this bug or similar to happen, so we don't throw full context about urls for every logic bug. By the time we land a fix, or add in enough context for you to faithfully debug this, you probably will get an answer more directly by either
|
Seems like a reasonable request if cache is corruptible (e.g. external file system changes) such that it doesn't always show a logic bug. If this type of runtime exception is possible because of external factors, we should probably also cleanup the cache instead of failing. |
For discussion, tests to confirm the fix after agreing on direction. |
Looks like the response metadata file is truncated, despite our atomic rename. Or we’re trying to use an HTTP cache entry to serve an HTTPS request?! |
So separating the cause from our handling of errors? Are you ok with the approach of preferring a mechanism to repair after failure? Otherwise we pretty much corrupt until you reinstall the App. |
I'd like to understand what's happening here. Is it a logic bug or is this file changing spontaneously? |
@ian-ellis this might be redundant but can you include the exception that you're seeing along with the stack trace? |
Another instance of this with 3.12.x Maybe best case here is to cleanly fail on corrupted base64 content instead of NPE? But will hide the bug. |
Also relevant #6453 |
I also encountered this problem, and found that basically it happened in the background (accounting for 98%). I guess the string resource was recycled by the system in the background, resulting in the scheme leaving only empty strings. |
Thanks for the context, much appreciated. We have changed the code to fail earlier, and we are working on better IO abstractions that should allow us to make it easier to debug this type of problem. If you are able to reliably reproduce this, please let me know and I'll give you a build to test with. Thanks! |
@swankjesse @yschimke any possible suggestions/workarounds to overcome this ?? Was it gracefully handled in any up-versions ?
|
Cache now takes a FileSystem, so I think there are options now for adding additional debugging if you can repro. Is anyone hitting this on 4.11 or 5.0.0-alpha11? |
I am currently trying to debug the following crash reported through firebase crashalytics for our Android application. Unfortunately but we cannot actually reproduce the issue, ourselves so the below stacktrace is all we have to go on.
It stems from the null coalescing found here:
okhttp/okhttp/src/main/kotlin/okhttp3/Cache.kt
Line 609 in fc6c29c
What is making this incredibly hard to debug is the lack of information about the request itself. Firstly we are not setting a cache on our own OKhttp instance, which leads me to suspect a third party lib. However, without knowing any details about the request that we are failing to read from the cache it is almost impossible to tell.
My suggestion is to instead of using
!!
on the decoded certificate, we null check and then throw aCertificateReadException
that provides more info about the response - mainly the URL but any other information that would be considered safe to end up in crash logs.sThe text was updated successfully, but these errors were encountered: