Hi,

I'm using Undertow 1.2.12.Final (for its Java 7 compatibility).

Let's says I have an exact path "/aaa/bbb" for which I want to chain two handlers managed by two PathHandlers:

- a SecurityInitialHandler
- a ResourceHandler

In other words, the "/aaa/bbb" exact path is a static resource and is protected.

The problem I found is that if the first PathHandler (the one for the SecurityInitialHandler) matches, then this code is called, in io.undertow.server.handlers.PathHandler#handleRequest(...) :

exchange.setRelativePath(match.getRemaining());

The "/aaa/bbb" path fully matches so the exchange's relativePath is set to "" after that match.

Then, the seconds PathHandler (the one for ResourceHandler) is run. The matching is done using:

match = pathMatcher.match(exchange.getRelativePath());

Since the relative path is now "", and not "/aaa/bbb", the ResourceHandler for "/aaa/bbb" is not used, even if it exists.

Worst, since the relative path is now "", the path to match will actually be converted to "/". This is because of io.undertow.util.PathMatcher#getExactPath(...) :

return exactPathMatches.get(URLUtils.normalizeSlashes(path));

The normalizeSlashes(path) method convert "" to "/".

This means that the default handler of the second PathHandler will be used for "/aaa/bbb". If the "/" static resource exists, it will be served instead of the "/aaa/bbb" resource.

Maybe I'm missing something about PathHandlers though... Any tips?

Thanks!

Julien