customizable-okhttp-logging-interceptor
customizable-okhttp-logging-interceptor copied to clipboard
Potential OOM issue when buffer?
https://github.com/bartek-wesolowski/customizable-okhttp-logging-interceptor/blob/05f13c021e2657a3f66f2852ef38a3b6fd5877b2/src/main/kotlin/com/bartoszwesolowski/okhttp3/logging/CustomizableHttpLoggingInterceptor.kt#L156
I see this line still read entire body to buffer. so I think this will cause OutOfMemoryError if body is big enough. (not tested yet)
Can we change it to maxBodyLength? But I think this will bring another issue with gzip content.
Thank you for the suggestion. I'll think about changing this, although, in fact, it might cause more issues with compressed content and displaying correct content length. If your responses contain hundreds of megabytes of data then you should probably not log them at all.
val buffer = Buffer()
requestBody.writeTo(buffer)
When uploading 1g files, the memory is full, and anr occurs.
Debugging found stuck in this line of code.
@imcloud ANRs don't occur because of full memory. They occur because of long running operations on the main thread. Are you sure you're not running your request on the main thread?
Your case seems to be very specific and I'm not sure if it would be the best idea to add this feature for everyone. It might be best for you to just copy the code of CustomizableHttpLoggingInterceptor (it's just one class) and customize it even more to skip logging some request bodies for specific requests or skip logging request bodies when they have a certain content type.
Thank you for your reply.Yes, I have skiped logging when uploading a file