Author: gnodet
Date: Mon Sep 25 01:24:27 2006
New Revision: 449602
URL: http://svn.apache.org/viewvc?view=rev&rev=449602
Log:
SM-583: Jetty context Path verification
Modified:
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
Modified:
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java?view=diff&rev=449602&r1=449601&r2=449602
==============================================================================
---
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
(original)
+++
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
Mon Sep 25 01:24:27 2006
@@ -155,6 +155,7 @@
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
+ String pathSlash = path + "/";
// Check that context does not exist yet
HandlerCollection handlerCollection = (HandlerCollection)
server.getHandler();
ContextHandlerCollection contexts = (ContextHandlerCollection)
handlerCollection.getHandlers()[0];
@@ -163,8 +164,9 @@
for (int i = 0; i < handlers.length; i++) {
if (handlers[i] instanceof ContextHandler) {
ContextHandler h = (ContextHandler) handlers[i];
- if (h.getContextPath().startsWith(path) ||
- path.startsWith(h.getContextPath())) {
+ String handlerPath = h.getContextPath() + "/";
+ if (handlerPath.startsWith(pathSlash) ||
+ pathSlash.startsWith(handlerPath)) {
throw new Exception("The requested context for path '"
+ path + "' overlaps with an existing context for path: '" + h.getContextPath()
+ "'");
}
}
Modified:
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java?view=diff&rev=449602&r1=449601&r2=449602
==============================================================================
---
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
(original)
+++
incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
Mon Sep 25 01:24:27 2006
@@ -86,6 +86,8 @@
server.createContext("http://localhost:8192/Service1/test1", new
TestHttpProcessor());
+ server.createContext("http://localhost:8192/Service1/test1ex", new
TestHttpProcessor());
+
try {
server.createContext("http://localhost:8192/Service1/test1", new
TestHttpProcessor());
fail("Contexts are overlapping, an exception should have been
thrown");