Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 567a22f26 -> 8e8f6f387
  refs/heads/master e05f42938 -> 40847e1ff


CXF-5610 check the context path conflict


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8e8f6f38
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8e8f6f38
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8e8f6f38

Branch: refs/heads/2.7.x-fixes
Commit: 8e8f6f387cf6ea2a5ce0b8d8629c12381c1a938b
Parents: 567a22f
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Fri Apr 4 18:57:07 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Fri Apr 4 18:59:05 2014 +0800

----------------------------------------------------------------------
 .../transport/http_jetty/JettyHTTPServerEngine.java   |  8 ++++++++
 .../http_jetty/JettyHTTPServerEngineTest.java         | 14 ++++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f6f38/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
 
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index 073805b..6a25ee3 100644
--- 
a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ 
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -280,6 +280,14 @@ public class JettyHTTPServerEngine
             if (path.equals(registedPath)) {
                 throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", 
LOG, url, registedPath));
             }
+            // There are some context path conflicts which could cause the 
JettyHTTPServerEngine 
+            // doesn't route the message to the right JettyHTTPHandler
+            if (path.equals(HttpUriMapper.getContextName(registedPath))) {
+                throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", 
LOG, url, registedPath));
+            }
+            if (registedPath.equals(HttpUriMapper.getContextName(path))) {
+                throw new Fault(new 
Message("ADD_HANDLER_CONTEXT_CONFILICT_MSG", LOG, url, registedPath));
+            }
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f6f38/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
 
b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
index 94aa022..b5ab2a6 100644
--- 
a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
+++ 
b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
@@ -200,6 +200,20 @@ public class JettyHTTPServerEngineTest extends Assert {
             assertTrue("Get a wrong exception message", 
ex.getMessage().indexOf("hello/test") > 0);
         }
         
+        try {
+            engine.addServant(new URL(urlStr + "/test"), handler2);
+            fail("We don't support to publish the two service at the same 
context path");
+        } catch (Exception ex) {
+            assertTrue("Get a wrong exception message", 
ex.getMessage().indexOf("hello/test/test") > 0);
+        }
+        
+        try {
+            engine.addServant(new URL("http://localhost:"; + PORT1 + "/hello"), 
handler2);
+            fail("We don't support to publish the two service at the same 
context path");
+        } catch (Exception ex) {
+            assertTrue("Get a wrong exception message", 
ex.getMessage().indexOf("hello") > 0);
+        }
+        
         engine.addServant(new URL(urlStr2), handler2);
         
         Set<ObjectName>  s = 
CastUtils.cast(ManagementFactory.getPlatformMBeanServer().

Reply via email to