You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/05 09:36:06 UTC

[camel] 01/02: Fixed NPE

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b913739c5e05b95da31d8765e70baafe22a0cbec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 5 10:22:44 2020 +0100

    Fixed NPE
---
 .../camel/component/netty/http/HttpClientInitializerFactory.java   | 7 ++++---
 .../camel/component/netty/http/HttpServerInitializerFactory.java   | 7 ++++---
 .../component/netty/http/HttpServerSharedInitializerFactory.java   | 7 ++++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
index 25c2a6d..fd1bdbd 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
@@ -149,9 +149,10 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
             if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
                 LOG.debug("truststorefile is null");
             }
-            if (configuration.getPassphrase().toCharArray() == null) {
+            if (configuration.getPassphrase() == null) {
                 LOG.debug("passphrase is null");
             }
+            char[] pw = configuration.getPassphrase() != null ? configuration.getPassphrase().toCharArray() : null;
 
             SSLEngineFactory sslEngineFactory;
             if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
@@ -161,7 +162,7 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
                         configuration.getSecurityProvider(),
                         "file:" + configuration.getKeyStoreFile().getPath(),
                         "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             } else {
                 sslEngineFactory = new SSLEngineFactory();
                 answer = sslEngineFactory.createSSLContext(producer.getContext(),
@@ -169,7 +170,7 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
                         configuration.getSecurityProvider(),
                         configuration.getKeyStoreResource(),
                         configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             }
         }
 
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
index 232e34e..3a57a83 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
@@ -151,9 +151,10 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
             if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
                 LOG.debug("truststorefile is null");
             }
-            if (configuration.getPassphrase().toCharArray() == null) {
+            if (configuration.getPassphrase() == null) {
                 LOG.debug("passphrase is null");
             }
+            char[] pw = configuration.getPassphrase() != null ? configuration.getPassphrase().toCharArray() : null;
 
             SSLEngineFactory sslEngineFactory;
             if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
@@ -163,7 +164,7 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
                         configuration.getSecurityProvider(),
                         "file:" + configuration.getKeyStoreFile().getPath(),
                         "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             } else {
                 sslEngineFactory = new SSLEngineFactory();
                 answer = sslEngineFactory.createSSLContext(camelContext,
@@ -171,7 +172,7 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
                         configuration.getSecurityProvider(),
                         configuration.getKeyStoreResource(),
                         configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             }
         }
 
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedInitializerFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedInitializerFactory.java
index 66db3ed..3886f7a 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedInitializerFactory.java
@@ -114,9 +114,10 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
             if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
                 LOG.debug("truststorefile is null");
             }
-            if (configuration.getPassphrase().toCharArray() == null) {
+            if (configuration.getPassphrase() == null) {
                 LOG.debug("passphrase is null");
             }
+            char[] pw = configuration.getPassphrase() != null ? configuration.getPassphrase().toCharArray() : null;
 
             SSLEngineFactory sslEngineFactory;
             if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
@@ -126,7 +127,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
                         configuration.getSecurityProvider(),
                         "file:" + configuration.getKeyStoreFile().getPath(),
                         "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             } else {
                 sslEngineFactory = new SSLEngineFactory();
                 answer = sslEngineFactory.createSSLContext(camelContext,
@@ -134,7 +135,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
                         configuration.getSecurityProvider(),
                         configuration.getKeyStoreResource(),
                         configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
+                        pw);
             }
         }