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:05 UTC

[camel] branch master updated (fd726b4 -> cbe39db)

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

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


    from fd726b4  Merge pull request #3612 from kawakamimanabu/typo_jcache
     new b913739  Fixed NPE
     new cbe39db  Fixed test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../netty/http/HttpClientInitializerFactory.java        |  7 ++++---
 .../netty/http/HttpServerInitializerFactory.java        |  7 ++++---
 .../netty/http/HttpServerSharedInitializerFactory.java  |  7 ++++---
 .../rest/openapi/RestOpenApiDelegateHttpsTest.java      | 15 +++++++++++----
 .../rest/openapi/RestOpenApiDelegateHttpsV3Test.java    | 17 ++++++++++++-----
 5 files changed, 35 insertions(+), 18 deletions(-)


[camel] 01/02: Fixed NPE

Posted by da...@apache.org.
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);
             }
         }
 


[camel] 02/02: Fixed test

Posted by da...@apache.org.
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 cbe39dbfc42f00ac177dfa416f4ee2cf1393a995
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 5 10:35:32 2020 +0100

    Fixed test
---
 .../rest/openapi/RestOpenApiDelegateHttpsTest.java      | 15 +++++++++++----
 .../rest/openapi/RestOpenApiDelegateHttpsV3Test.java    | 17 ++++++++++++-----
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsTest.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsTest.java
index fcd5cc0d..da1e1e7 100644
--- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsTest.java
+++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsTest.java
@@ -18,9 +18,8 @@ package org.apache.camel.component.rest.openapi;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
-import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spi.BeanIntrospection;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
@@ -31,11 +30,19 @@ public class RestOpenApiDelegateHttpsTest extends HttpsTest {
     protected CamelContext createCamelContext() throws Exception {
         final CamelContext camelContext = super.createCamelContext();
 
+        // since camel context is not started, then we need to manually initialize the delegate
         final Component delegate = ((DefaultCamelContext) camelContext).getComponentResolver()
             .resolveComponent(componentName, camelContext);
+        delegate.setCamelContext(camelContext);
+        delegate.init();
 
-        BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
-        beanIntrospection.setProperty(camelContext, delegate, "sslContextParameters", createHttpsParameters(camelContext));
+        // and configure the ssl context parameters via binding
+        new PropertyBindingSupport.Builder()
+                .withCamelContext(camelContext)
+                .withProperty("sslContextParameters", createHttpsParameters(camelContext))
+                .withTarget(delegate)
+                .withConfigurer(delegate.getComponentPropertyConfigurer())
+                .bind();
         camelContext.addComponent(componentName, delegate);
 
         return camelContext;
diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsV3Test.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsV3Test.java
index 736c09c..d1bb09a 100644
--- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsV3Test.java
+++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiDelegateHttpsV3Test.java
@@ -18,9 +18,8 @@ package org.apache.camel.component.rest.openapi;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
-import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spi.BeanIntrospection;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
@@ -31,11 +30,19 @@ public class RestOpenApiDelegateHttpsV3Test extends HttpsV3Test {
     protected CamelContext createCamelContext() throws Exception {
         final CamelContext camelContext = super.createCamelContext();
 
+        // since camel context is not started, then we need to manually initialize the delegate
         final Component delegate = ((DefaultCamelContext) camelContext).getComponentResolver()
-            .resolveComponent(componentName, camelContext);
+                .resolveComponent(componentName, camelContext);
+        delegate.setCamelContext(camelContext);
+        delegate.init();
 
-        BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
-        beanIntrospection.setProperty(camelContext, delegate, "sslContextParameters", createHttpsParameters(camelContext));
+        // and configure the ssl context parameters via binding
+        new PropertyBindingSupport.Builder()
+                .withCamelContext(camelContext)
+                .withProperty("sslContextParameters", createHttpsParameters(camelContext))
+                .withTarget(delegate)
+                .withConfigurer(delegate.getComponentPropertyConfigurer())
+                .bind();
         camelContext.addComponent(componentName, delegate);
 
         return camelContext;