camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [02/12] camel git commit: CAMEL-10381 - fix NPE from component configuration
Date Wed, 12 Oct 2016 02:16:30 GMT
CAMEL-10381 - fix NPE from component configuration


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

Branch: refs/heads/master
Commit: fab550a7e21467acff6307e707c09d4a90820267
Parents: 404ecc5
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Tue Oct 11 19:47:27 2016 -0230
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Tue Oct 11 19:47:27 2016 -0230

----------------------------------------------------------------------
 .../component/google/drive/GoogleDriveComponent.java      | 10 +++++++---
 .../camel/component/google/drive/GoogleDriveEndpoint.java |  2 +-
 .../component/google/drive/GoogleDriveFilesConverter.java |  3 ++-
 3 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fab550a7/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveComponent.java
b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveComponent.java
index 2554d0e..84dc9e2 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveComponent.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveComponent.java
@@ -44,10 +44,11 @@ public class GoogleDriveComponent extends AbstractApiComponent<GoogleDriveApiNam
         return GoogleDriveApiName.fromValue(apiNameStr);
     }
 
-    public Drive getClient() {
+    public Drive getClient(GoogleDriveConfiguration googleDriveConfiguration) {
         if (client == null) {
-            client = getClientFactory().makeClient(configuration.getClientId(), configuration.getClientSecret(),
configuration.getScopes(), 
-                configuration.getApplicationName(), configuration.getRefreshToken(), configuration.getAccessToken());
+            client = getClientFactory().makeClient(googleDriveConfiguration.getClientId(),
googleDriveConfiguration.getClientSecret(), 
+                    googleDriveConfiguration.getScopes(), googleDriveConfiguration.getApplicationName(),

+                    googleDriveConfiguration.getRefreshToken(), googleDriveConfiguration.getAccessToken());
         }
         return client;
     }
@@ -69,6 +70,9 @@ public class GoogleDriveComponent extends AbstractApiComponent<GoogleDriveApiNam
 
     @Override
     public GoogleDriveConfiguration getConfiguration() {
+        if (configuration == null) {
+            configuration = new GoogleDriveConfiguration();
+        }
         return super.getConfiguration();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fab550a7/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
index ede52d5..b80a2df 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
@@ -124,7 +124,7 @@ public class GoogleDriveEndpoint extends AbstractApiEndpoint<GoogleDriveApiName,
     }
     
     public Drive getClient() {
-        return ((GoogleDriveComponent)getComponent()).getClient();
+        return ((GoogleDriveComponent)getComponent()).getClient(configuration);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/fab550a7/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverter.java
b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverter.java
index 7d43705..d227301 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverter.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverter.java
@@ -98,6 +98,7 @@ public final class GoogleDriveFilesConverter {
     }
     
     private static Drive getClient(Exchange exchange) {
-        return exchange.getContext().getComponent("google-drive", GoogleDriveComponent.class).getClient();
+        GoogleDriveComponent component = exchange.getContext().getComponent("google-drive",
GoogleDriveComponent.class);
+        return component.getClient(component.getConfiguration());
     }
 }


Mime
View raw message