Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNDERTOW-1581: Fix RoutingHandler allMethodsMatcher validation #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/main/java/io/undertow/server/RoutingHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be like in https://github.com/undertow-io/undertow/pull/799/files#diff-b365caf66586093f040e0a2915a095a4bf1f4ed87343a31998507406f358e827R132?

Suggested change
exchange.writeAsync("foo-path" + exchange.getQueryParameters().get("bar"));
exchange.getResponseSender().send("foo-path" + exchange.getQueryParameters().get("bar"));

}
})
.add(HttpMethodNames.GET, "/foo/{bar}", new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
Expand Down
Loading