cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CXF-5610 check the context path conflict
Date Fri, 04 Apr 2014 10:59:38 GMT
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/40847e1f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/40847e1f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/40847e1f

Branch: refs/heads/master
Commit: 40847e1ff65c7c543f7165534887692d9915f971
Parents: e05f429
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Apr 4 18:57:07 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Apr 4 18:59:26 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/40847e1f/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/40847e1f/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().


Mime
View raw message