camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6348: Fixed getting and restoring JAAS Configuration if non existed. Thanks to David Arthur for the patch.
Date Fri, 10 May 2013 13:43:53 GMT
Updated Branches:
  refs/heads/camel-2.10.x f7697b6ef -> 69dac4300
  refs/heads/camel-2.11.x fa7dd10f3 -> 9e709b24c


CAMEL-6348: Fixed getting and restoring JAAS Configuration if non existed. Thanks to David
Arthur for the patch.


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

Branch: refs/heads/camel-2.11.x
Commit: 9e709b24cb8a4d75cfa0b16f5b2fe59b24187ad5
Parents: fa7dd10
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri May 10 15:42:51 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri May 10 15:43:16 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/component/hdfs/HdfsComponent.java |   25 +++++++++++++++
 .../apache/camel/component/hdfs/HdfsConsumer.java  |    8 +---
 .../camel/component/hdfs/HdfsInfoFactory.java      |    8 +---
 .../apache/camel/component/hdfs/HdfsProducer.java  |   16 ++-------
 4 files changed, 33 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9e709b24/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
index 76baa99..1920e1c 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsComponent.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.hdfs;
 
 import java.net.URL;
 import java.util.Map;
+import javax.security.auth.login.Configuration;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
@@ -54,4 +55,28 @@ public class HdfsComponent extends DefaultComponent {
         }
     }
 
+    static Configuration getJAASConfiguration() {
+        Configuration auth = null;
+        try {
+            auth = Configuration.getConfiguration();
+            LOG.trace("Existing JAAS Configuration {}", auth);
+        } catch (SecurityException e) {
+            LOG.trace("Cannot load existing JAAS configuration", e);
+        }
+        return auth;
+    }
+
+    static void setJAASConfiguration(Configuration auth) {
+        if (auth != null) {
+            LOG.trace("Restoring existing JAAS Configuration {}", auth);
+            try {
+                Configuration.setConfiguration(auth);
+            } catch (SecurityException e) {
+                LOG.trace("Cannot restore JAAS Configuration. This exception is ignored.",
e);
+            }
+        } else {
+            LOG.trace("No JAAS Configuration to restore");
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/9e709b24/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConsumer.java
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConsumer.java
index 8a6e0ba..b24a9ea 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConsumer.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConsumer.java
@@ -93,15 +93,11 @@ public final class HdfsConsumer extends ScheduledPollConsumer {
     @Override
     protected int poll() throws Exception {
         // need to remember auth as Hadoop will override that, which otherwise means the
Auth is broken afterwards
-        Configuration auth = Configuration.getConfiguration();
-        log.trace("Existing JAAS Configuration {}", auth);
+        Configuration auth = HdfsComponent.getJAASConfiguration();
         try {
             return doPoll();
         } finally {
-            if (auth != null) {
-                log.trace("Restoring existing JAAS Configuration {}", auth);
-                Configuration.setConfiguration(auth);
-            }
+            HdfsComponent.setJAASConfiguration(auth);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9e709b24/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsInfoFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsInfoFactory.java
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsInfoFactory.java
index 0766ea3..9511c64 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsInfoFactory.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsInfoFactory.java
@@ -31,15 +31,11 @@ public final class HdfsInfoFactory {
 
     public static HdfsInfo newHdfsInfo(String hdfsPath) throws IOException {
         // need to remember auth as Hadoop will override that, which otherwise means the
Auth is broken afterwards
-        Configuration auth = Configuration.getConfiguration();
-        LOG.trace("Existing JAAS Configuration {}", auth);
+        Configuration auth = HdfsComponent.getJAASConfiguration();
         try {
             return new HdfsInfo(hdfsPath);
         } finally {
-            if (auth != null) {
-                LOG.trace("Restoring existing JAAS Configuration {}", auth);
-                Configuration.setConfiguration(auth);
-            }
+            HdfsComponent.setJAASConfiguration(auth);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9e709b24/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
index 7e7d195..2c3c0f5 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsProducer.java
@@ -94,8 +94,7 @@ public class HdfsProducer extends DefaultProducer {
     @Override
     protected void doStart() throws Exception {
         // need to remember auth as Hadoop will override that, which otherwise means the
Auth is broken afterwards
-        Configuration auth = Configuration.getConfiguration();
-        log.trace("Existing JAAS Configuration {}", auth);
+        Configuration auth = HdfsComponent.getJAASConfiguration();
         try {
             super.doStart();
 
@@ -117,10 +116,7 @@ public class HdfsProducer extends DefaultProducer {
                 scheduler.scheduleAtFixedRate(new IdleCheck(idleStrategy), config.getCheckIdleInterval(),
config.getCheckIdleInterval(), TimeUnit.MILLISECONDS);
             }
         } finally {
-            if (auth != null) {
-                log.trace("Restoring existing JAAS Configuration {}", auth);
-                Configuration.setConfiguration(auth);
-            }
+            HdfsComponent.setJAASConfiguration(auth);
         }
     }
 
@@ -172,15 +168,11 @@ public class HdfsProducer extends DefaultProducer {
     @Override
     public void process(Exchange exchange) throws Exception {
         // need to remember auth as Hadoop will override that, which otherwise means the
Auth is broken afterwards
-        Configuration auth = Configuration.getConfiguration();
-        log.trace("Existing JAAS Configuration {}", auth);
+        Configuration auth = HdfsComponent.getJAASConfiguration();
         try {
             doProcess(exchange);
         } finally {
-            if (auth != null) {
-                log.trace("Restoring existing JAAS Configuration {}", auth);
-                Configuration.setConfiguration(auth);
-            }
+            HdfsComponent.setJAASConfiguration(auth);
         }
     }
 


Mime
View raw message