From 985e78e2f302349b37e9698e652229a01a1f31b1 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 25 Oct 2023 12:37:48 +0200 Subject: [PATCH] Vert.x: fix NPE in ForwardedProxyHandler 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. --- .../io/quarkus/vertx/http/runtime/ForwardedProxyHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedProxyHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedProxyHandler.java index cde4f0d034fd8..82c548558a30b 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedProxyHandler.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedProxyHandler.java @@ -79,7 +79,7 @@ private void lookupHostNamesAndHandleRequest(HttpServerRequest event, new Handler>() { @Override public void handle(AsyncResult 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