-
Notifications
You must be signed in to change notification settings - Fork 33
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
Setting log level to BODY deactivates EventHandler #57
Comments
At first glance, it looks to me like the implementation of But that assumes that the response is finite. A streaming response, as long as the connection is still alive, doesn't end... so the interceptor never stops buffering, and the client code never gets to see the response data. That would be my guess. My recommendation would be basically "don't do that"; what is it exactly that you're hoping to accomplish in this case by turning on the |
I set the log level to |
I take your point, but... the existence of the interceptor mechanism in OkHttp makes it impossible for any client code that accepts a pre-configured OkHttp client to guarantee that an interceptor won't interfere with responses somehow. And the way HttpLoggingInterceptor is written, it is not really just a logging component; it transforms the response, and it blocks all further processing until the response is complete, which is totally inappropriate for use with any streaming API. I wish they had documented that a bit better (or at all, really) since indeed most people wouldn't expect logging to have side effects like that. I think at a minimum we should add some documentation of our own—probably in the doc comments for I'm less sure about your suggestion of having |
In fact, it looks like this is a known issue which they've decided not to address: |
(Another reason not to do the "inspect the interceptors" thing is that if the OkHttp maintainers changed their mind and actually fixed |
use LaunchDarkly logging facade
Configuring
EventSource
withOkHttpClient
usingHttpLoggingInterceptor
with log level set toBODY
deactivatesEventHandler
. MethodonMessage
will not execute any more.No other log levels cause this problem. Reproducible on Java 8 and 11.
Complete project with fully reproducible scenario: here.
This is either a very unusual defect, or there must be something that I missed.
The text was updated successfully, but these errors were encountered: