camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [4/5] camel git commit: CAMEL-8036 JettyComponent should not setup the security handler more than once
Date Wed, 12 Nov 2014 09:15:33 GMT
CAMEL-8036 JettyComponent should not setup the security handler more than once


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

Branch: refs/heads/master
Commit: 9378d293ed0862a8a4e0a699f16e75777647346d
Parents: 11a0549
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Nov 12 17:14:10 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Nov 12 17:14:38 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/component/jetty/JettyHttpComponent.java  | 7 +++++--
 .../component/jetty/HttpBasicAuthComponentConfiguredTest.java | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9378d293/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 71c3f1e..f2a10ce 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1075,8 +1075,11 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
         if (handlers != null && !handlers.isEmpty()) {
             for (Handler handler : handlers) {
                 if (handler instanceof HandlerWrapper) {
-                    ((HandlerWrapper) handler).setHandler(server.getHandler());
-                    server.setHandler(handler);
+                    // avoid setting the security handler more than once
+                    if (!handler.equals(server.getHandler())) {
+                        ((HandlerWrapper) handler).setHandler(server.getHandler());
+                        server.setHandler(handler);
+                    }
                 } else {
                     HandlerCollection handlerCollection = new HandlerCollection();
                     handlerCollection.addHandler(server.getHandler());

http://git-wip-us.apache.org/repos/asf/camel/blob/9378d293/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
index a34ffa9..18fccfc 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
@@ -71,6 +71,9 @@ public class HttpBasicAuthComponentConfiguredTest extends BaseJettyTest
{
     public void testHttpBasicAuth() throws Exception {
         String out = template.requestBody("http://localhost:{{port}}/test", "Hello World",
String.class);
         assertEquals("Bye World", out);
+        
+        out = template.requestBody("http://localhost:{{port}}/anotherTest", "Hello World",
String.class);
+        assertEquals("See you later", out);
     }
 
     @Override
@@ -97,6 +100,9 @@ public class HttpBasicAuthComponentConfiguredTest extends BaseJettyTest
{
                         }
                     })
                     .transform(constant("Bye World"));
+                
+                from("jetty://http://localhost:{{port}}/anotherTest?handlers=myAuthHandler")
+                    .transform(constant("See you later"));
             }
         };
     }


Mime
View raw message