The current behavior (clarified in https://bugs.openjdk.java.net/browse/JDK-8225479) is contexts can be created without a trailing slash. This can lead to surprising behavior where for example a context of /foo will match /foobar.
8225479 decided to just document it, but it seems safer to change the behavior to something less surprising.
The proposal is to silently add a '/' to any context path that doesn't already have one at each time of use. It probably makes sense to record the context exactly as the caller specified it (with or without the '/') and return the same path from HttpContext.getPath. Otherwise, that could result in surprising behavior after the change (getPath() returning a different path to the one specified).
The reason for silently adding the '/' is to support the most likely misuse of the current behavior ie registering /foo while intending the behavior of /foo/
This will break other less likely misuses such as /foobar, which currently do work
8225479 decided to just document it, but it seems safer to change the behavior to something less surprising.
The proposal is to silently add a '/' to any context path that doesn't already have one at each time of use. It probably makes sense to record the context exactly as the caller specified it (with or without the '/') and return the same path from HttpContext.getPath. Otherwise, that could result in surprising behavior after the change (getPath() returning a different path to the one specified).
The reason for silently adding the '/' is to support the most likely misuse of the current behavior ie registering /foo while intending the behavior of /foo/
This will break other less likely misuses such as /foobar, which currently do work
- relates to
-
JDK-8225479 com.sun.net.httpserver.HttpContext that does not end with '/' has surprising matches
-
- Resolved
-