From e3c661daac69cdb2de43c3d66d9ed1ccc9c8dbc6 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Fri, 19 Jan 2018 12:42:47 -0500 Subject: [PATCH] NIFI-4761 Fixing test case regression. This closes #2418. Signed-off-by: Andy LoPresto --- .../apache/nifi/web/server/HostHeaderHandler.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java index 9a07fcbdd4..72e8d8425a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java @@ -70,15 +70,20 @@ public class HostHeaderHandler extends ScopedHandler { this.serverName = Objects.requireNonNull(serverName); this.serverPort = serverPort; - // Default values across generic instances validHosts = generateDefaultHostnames(null); - - // specified host:port validHosts.add(serverName.toLowerCase()); validHosts.add(serverName.toLowerCase() + ":" + serverPort); - - // empty is ok here + // Sometimes the hostname is left empty but the port is always populated + validHosts.add("localhost"); + validHosts.add("localhost:" + serverPort); + // Different from customizer -- empty is ok here validHosts.add(""); + try { + validHosts.add(InetAddress.getLocalHost().getHostName().toLowerCase()); + validHosts.add(InetAddress.getLocalHost().getHostName().toLowerCase() + ":" + serverPort); + } catch (final Exception e) { + logger.warn("Failed to determine local hostname.", e); + } logger.info("Created " + this.toString()); }