Skip to content

Commit

Permalink
Vert.x: fix NPE in ForwardedProxyHandler
Browse files Browse the repository at this point in the history
The test `TrustedXForwarderProxiesUnknownHostnameFailureTest` sometimes fail
in CI due to a NPE in `ForwardedProxyHandler`. This shows an actual bug:
per the documentation, `io.vertx.core.dns.DnsClient.lookup()` may succeed
with a `null` value when no record was found. The `ForwardedProxyHandler`
ignores the possibility of a `null` result, which this commit fixes. We deal
with a `null` result just like with a failure, because it's equivalent
to a NXDOMAIN error.
  • Loading branch information
Ladicek committed Oct 25, 2023
1 parent 7a3fd94 commit 985e78e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void lookupHostNamesAndHandleRequest(HttpServerRequest event,
new Handler<AsyncResult<String>>() {
@Override
public void handle(AsyncResult<String> stringAsyncResult) {
if (stringAsyncResult.succeeded()) {
if (stringAsyncResult.succeeded() && stringAsyncResult.result() != null) {
var trustedIP = Inet.parseInetAddress(stringAsyncResult.result());
if (trustedIP != null) {
// create proxy check for resolved IP and proceed with the lookup
Expand Down

0 comments on commit 985e78e

Please sign in to comment.