Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2015-08-28 16:19:14 +0000
committerThomas Watson2015-08-28 16:31:50 +0000
commitd56bdf10278de5bf2c36745ccac842190eeb72c6 (patch)
tree3a7c821771337fb50d2ad33ba1c387c48f237261 /bundles
parent13eeb0a927112cb4ce73258f8a460f5f9199a703 (diff)
downloadrt.equinox.bundles-d56bdf10278de5bf2c36745ccac842190eeb72c6.tar.gz
rt.equinox.bundles-d56bdf10278de5bf2c36745ccac842190eeb72c6.tar.xz
rt.equinox.bundles-d56bdf10278de5bf2c36745ccac842190eeb72c6.zip
Bug 476136 - [http whiteboard] using legacy servlet registration does
not allow exact matching to take precidence
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java33
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java12
2 files changed, 39 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
index ce0ce6c1..8727d410 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
@@ -1726,6 +1726,39 @@ public class ServletTest extends TestCase {
Assert.assertEquals("p=1&p=2|1|[1, 2]", result);
}
+ public void test_ServletExactMatchPrecidence() throws Exception {
+ Servlet sA = new HttpServlet() {
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ response.getWriter().write('a');
+ }
+
+ };
+
+ Servlet sB = new HttpServlet() {
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ response.getWriter().write('b');
+ }
+
+ };
+
+ HttpService httpService = getHttpService();
+
+ HttpContext httpContext = httpService.createDefaultHttpContext();
+
+ httpService.registerServlet("*.txt", sA, null, httpContext);
+ httpService.registerServlet("/files/help.txt", sB, null, httpContext);
+
+ Assert.assertEquals("b", requestAdvisor.request("files/help.txt"));
+ }
+
private static String getSubmittedFileName(Part part) {
for (String cd : part.getHeader("content-disposition").split(";")) {
if (cd.trim().startsWith("filename")) {
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
index d363b698..9e28f58f 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
@@ -692,13 +692,13 @@ public class HttpServiceRuntimeImpl
// check the pattern against the original input
ContextController.checkPattern(alias);
- String pattern = alias;
- // need to make sure exact matching aliases are converted to wildcard pattern matches
- if (!pattern.endsWith(Const.SLASH_STAR) && !pattern.startsWith(Const.STAR_DOT) && !pattern.contains(Const.SLASH_STAR_DOT)) {
- if (pattern.endsWith(Const.SLASH)) {
- pattern = pattern + '*';
+ Object pattern = alias;
+ // need to make sure exact matching aliases are converted to exact matching + wildcard pattern matching
+ if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) && !alias.contains(Const.SLASH_STAR_DOT)) {
+ if (alias.endsWith(Const.SLASH)) {
+ pattern = new String[] {alias, alias + '*'};
} else {
- pattern = pattern + Const.SLASH_STAR;
+ pattern = new String[] {alias, alias + Const.SLASH_STAR};
}
}

Back to the top