You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
The code in doConnection has try catch on connectFunc and then on toResponse, but the method toResponse invokes the parser (callback from user), so that's very bad.
Instead of only handling errors during connection - it also handles errors in the user code, without them being aware.
consider the following scenario:
Connection established correctly, 200
The parser (not the connection function!) throws an IOException. this gets caught - and disappears. No handling, logging or propagation!
The parser is invoked once again! This time, the parser is passed the error stream, which is null because the status code was 200. the callback sees 200, handles as success and blows up on null pointer exception.
generally speaking, IMO, connectFunc should be wrapped in try catch, the user callback should not have any catch (but finally and stream cleanup is ok).
FYI
The text was updated successfully, but these errors were encountered:
don't have capacity at this time to dig into this code, it may be good but i remember it was complicated.
we will discuss how and when we or someone from the company can help with this internally.
in the meanwhile, an easy workaround is for the consumer to wrap their call back in try catch and wrap all exceptions, thus making sure not to throw a java.io.IOException
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
The code in doConnection has try catch on connectFunc and then on toResponse, but the method toResponse invokes the parser (callback from user), so that's very bad.
Instead of only handling errors during connection - it also handles errors in the user code, without them being aware.
consider the following scenario:
scalaj-http/src/main/scala/scalaj/http/Http.scala
Line 363 in 40c17af
generally speaking, IMO, connectFunc should be wrapped in try catch, the user callback should not have any catch (but finally and stream cleanup is ok).
FYI
The text was updated successfully, but these errors were encountered: