From 576e71f5bfca629a7c25b4cbc02cf4e1029f0835 Mon Sep 17 00:00:00 2001 From: Radoslav Husar Date: Wed, 2 Dec 2015 01:45:12 +0100 Subject: [PATCH] WFLY-5756 Unable to exclude root context (/) via excluded-contexts in mod_cluster subsystem --- .../org/wildfly/mod_cluster/undertow/UndertowContext.java | 3 ++- .../java/org/wildfly/mod_cluster/undertow/UndertowHost.java | 4 +++- .../wildfly/mod_cluster/undertow/UndertowContextTestCase.java | 2 +- .../wildfly/mod_cluster/undertow/UndertowHostTestCase.java | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowContext.java b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowContext.java index f93eea22b6ca..1c3c6a0af88e 100644 --- a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowContext.java +++ b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowContext.java @@ -59,7 +59,8 @@ public Host getHost() { @Override public String getPath() { - return this.deployment.getDeploymentInfo().getContextPath(); + String path = this.deployment.getDeploymentInfo().getContextPath(); + return "/".equals(path) ? "" : path; } @Override diff --git a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowHost.java b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowHost.java index 36efa8abcfc0..e8a2ea100c99 100644 --- a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowHost.java +++ b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowHost.java @@ -93,8 +93,10 @@ public Set getAliases() { @Override public Context findContext(String path) { + String findPath = "".equals(path) ? "/" : path; + for (Deployment deployment : this.host.getDeployments()) { - if (deployment.getDeploymentInfo().getContextPath().equals(path)) { + if (deployment.getDeploymentInfo().getContextPath().equals(findPath)) { return new UndertowContext(deployment, this); } } diff --git a/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowContextTestCase.java b/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowContextTestCase.java index c478310dc361..8ba2348a8bed 100644 --- a/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowContextTestCase.java +++ b/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowContextTestCase.java @@ -58,7 +58,7 @@ public void getHost() { @Test public void getPath() { DeploymentInfo info = new DeploymentInfo(); - String expected = "/"; + String expected = ""; info.setContextPath(expected); when(this.deployment.getDeploymentInfo()).thenReturn(info); diff --git a/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowHostTestCase.java b/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowHostTestCase.java index fed5597297bc..d57ed881b35e 100644 --- a/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowHostTestCase.java +++ b/mod_cluster/undertow/src/test/java/org/wildfly/mod_cluster/undertow/UndertowHostTestCase.java @@ -68,7 +68,7 @@ public void getEngine() { public void getContexts() { Deployment deployment = mock(Deployment.class); DeploymentInfo info = new DeploymentInfo(); - String expectedPath = "/"; + String expectedPath = ""; info.setContextPath(expectedPath); HttpHandler handler = mock(HttpHandler.class); @@ -89,7 +89,7 @@ public void getContexts() { public void findContext() { Deployment deployment = mock(Deployment.class); DeploymentInfo info = new DeploymentInfo(); - String expectedPath = "/"; + String expectedPath = ""; info.setContextPath(expectedPath); HttpHandler handler = mock(HttpHandler.class);