-
Notifications
You must be signed in to change notification settings - Fork 983
Fix NPE in InternalAbstractHttpAsyncClient by adding null check for resolvedTarget #634
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
Conversation
| } | ||
| if (request.getAuthority() == null) { | ||
| request.setAuthority(new URIAuthority(resolvedTarget)); | ||
| if (resolvedTarget != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @arturobernalg 👋
We could throw a more precise exception using Objects.requireNonNull(...), which would reduce the nesting. See also org.apache.hc.core5.util.Args.notNull(T, String)
db53767 to
622c043
Compare
| setupContext(clientContext); | ||
|
|
||
| final HttpHost resolvedTarget = target != null ? target : RoutingSupport.determineHost(request); | ||
| Args.notNull(resolvedTarget, "Target host for the request"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arturobernalg This is not right. The target may be null if the request URI cannot be parsed. It should be up to the specific protocol handler to decide if such a request can be executed. H2 will likely reject it but HTTP/1.1 may accept it
…g null check for resolvedTarget.
928d79d to
3515abf
Compare
|
@ok2c should I wait for the original reporter’s feedback before merging? |
@arturobernalg I do not think it is necessary. The fix is quite straight-forward. |
…g null check for resolvedTarget. (#634)
…g null check for resolvedTarget. (#634)
|
@arturobernalg I tweaked the test case a little to make it behave it more similarly to the default route planner. |
|
👍 |
thank you @ok2c |
Resolves a
NullPointerExceptioninInternalAbstractHttpAsyncClientby adding a null check for resolvedTarget when RoutingSupport.determineHost returns null. ThrowsIllegalStateExceptionfor invalid requests, ensuring robust error handling. Addresses HTTPCLIENT-2367.