CXF-5740 Added a system property to stop checking the url

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

Branch: refs/heads/2.6.x-fixes
Commit: d8fbcd0c20d4e1878ab89b4027e3d4a26e21f0fe
Parents: 100cf6e
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu May 22 15:26:44 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu May 22 16:19:46 2014 +0800

----------------------------------------------------------------------
 .../http_jetty/JettyHTTPServerEngine.java       | 33 +++++++++++++-------
 .../http_jetty/JettyHTTPServerEngineTest.java   |  6 ++++
 2 files changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d8fbcd0c/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 154e8b9..5e33fb5 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
@@ -99,6 +99,7 @@ public class JettyHTTPServerEngine
     private Container.Listener mBeanContainer;
     private SessionManager sessionManager;
     
+    
     /**
      * This field holds the TLS ServerParameters that are programatically
      * configured. The tlsServerParamers (due to JAXB) holds the struct
@@ -210,6 +211,12 @@ public class JettyHTTPServerEngine
         return !Boolean.valueOf(s);
     }
     
+    private boolean shouldCheckUrl() {
+        String s = SystemPropertyAction
+            
.getPropertyOrNull("org.apache.cxf.transports.http_jetty.DontCheckUrl");
+        return !Boolean.valueOf(s);
+    }
+    
     /**
      * get the jetty server instance
      * @return
@@ -276,18 +283,20 @@ public class JettyHTTPServerEngine
     }
     
     protected void checkRegistedContext(URL url) {
-        String path = url.getPath();
-        for (String registedPath : registedPaths) {
-            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));
+        if (shouldCheckUrl()) {
+            String path = url.getPath();
+            for (String registedPath : registedPaths) {
+                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/d8fbcd0c/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 add1e86..63743a3 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
@@ -214,6 +214,12 @@ public class JettyHTTPServerEngineTest extends Assert {
             assertTrue("Get a wrong exception message", 
ex.getMessage().indexOf("hello") > 0);
         }
         
+        // check if the system property change could work
+        
System.setProperty("org.apache.cxf.transports.http_jetty.DontCheckUrl", "true");
+        engine.addServant(new URL(urlStr + "/test"), handler2);
+        // clean up the System property setting
+        
System.clearProperty("org.apache.cxf.transports.http_jetty.DontCheckUrl");
+        
         engine.addServant(new URL(urlStr2), handler2);
         
         Set<ObjectName>  s = 
CastUtils.cast(ManagementFactory.getPlatformMBeanServer().

Reply via email to