camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] camel git commit: CAMEL-8036 JettyComponent should not setup the security handler more than once
Date Wed, 12 Nov 2014 10:50:42 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x aae2e24d2 -> ebf9b1fa6
  refs/heads/camel-2.14.x 55e096c05 -> 80e93e5d3


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/80e93e5d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/80e93e5d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/80e93e5d

Branch: refs/heads/camel-2.14.x
Commit: 80e93e5d31ea56ca6ef673eca5ac8ee86cefefb4
Parents: 55e096c
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 18:50:07 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/80e93e5d/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/80e93e5d/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