diff --git a/core/src/main/java/io/undertow/server/RoutingHandler.java b/core/src/main/java/io/undertow/server/RoutingHandler.java index e873b94b4..8603d0b6f 100644 --- a/core/src/main/java/io/undertow/server/RoutingHandler.java +++ b/core/src/main/java/io/undertow/server/RoutingHandler.java @@ -120,7 +120,7 @@ public synchronized RoutingHandler add(String method, String template, HttpHandl if (res == null) { matcher.add(template, res = new RoutingMatch()); } - if (allMethodsMatcher.get(template) == null) { + if (allMethodsMatcher.match(template) == null) { allMethodsMatcher.add(template, res); } res.defaultHandler = handler; @@ -152,7 +152,7 @@ public synchronized RoutingHandler add(String method, String template, Predicate if (res == null) { matcher.add(template, res = new RoutingMatch()); } - if (allMethodsMatcher.get(template) == null) { + if (allMethodsMatcher.match(template) == null) { allMethodsMatcher.add(template, res); } res.predicatedHandlers.add(new HandlerHolder(predicate, handler)); @@ -186,7 +186,7 @@ public synchronized RoutingHandler addAll(RoutingHandler routingHandler) { // If we use allMethodsMatcher.addAll() we can have duplicate // PathTemplates which we want to ignore here so it does not crash. for (PathTemplate template : entry.getValue().getPathTemplates()) { - if (allMethodsMatcher.get(template.getTemplateString()) == null) { + if (allMethodsMatcher.match(template.getTemplateString()) == null) { allMethodsMatcher.add(template, new RoutingMatch()); } } diff --git a/core/src/test/java/io/undertow/server/handlers/RoutingHandlerTestCase.java b/core/src/test/java/io/undertow/server/handlers/RoutingHandlerTestCase.java index 1ad0994f0..48eb89b79 100644 --- a/core/src/test/java/io/undertow/server/handlers/RoutingHandlerTestCase.java +++ b/core/src/test/java/io/undertow/server/handlers/RoutingHandlerTestCase.java @@ -126,6 +126,12 @@ public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.writeAsync("posted foo"); } }) + .add(HttpMethodNames.POST, "/foo/{baz}", new HttpHandler() { + @Override + public void handleRequest(HttpServerExchange exchange) throws Exception { + exchange.writeAsync("foo-path" + exchange.getQueryParameters().get("bar")); + } + }) .add(HttpMethodNames.GET, "/foo/{bar}", new HttpHandler() { @Override public void handleRequest(HttpServerExchange exchange) throws Exception {