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


The following commit(s) were added to refs/heads/master by this push:
     new 2285620  CAMEL-16313 camel-splunk: can not use component without 
credentials (to be able to communicate with free splunk server) (#5184)
2285620 is described below

commit 228562092c509f71d8ebac50dd0baa63b0ce09e9
Author: JiriOndrusek <ondrusek.j...@gmail.com>
AuthorDate: Mon Mar 8 16:56:46 2021 +0100

    CAMEL-16313 camel-splunk: can not use component without credentials (to be 
able to communicate with free splunk server) (#5184)
---
 .../camel/component/splunk/SplunkConnectionFactory.java       |  9 ++++++---
 .../component/splunk/SplunkComponentConfigurationTest.java    | 11 +++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/SplunkConnectionFactory.java
 
b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/SplunkConnectionFactory.java
index eb3828d..b5da29f 100644
--- 
a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/SplunkConnectionFactory.java
+++ 
b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/SplunkConnectionFactory.java
@@ -112,9 +112,12 @@ public class SplunkConnectionFactory {
         if (owner != null) {
             args.setOwner(owner);
         }
-
-        args.setUsername(username);
-        args.setPassword(password);
+        if (username != null) {
+            args.setUsername(username);
+        }
+        if (password != null) {
+            args.setPassword(password);
+        }
         // useful in cases where you want to bypass app. servers https handling
         // (wls i'm looking at you)
         if (isUseSunHttpsHandler()) {
diff --git 
a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/SplunkComponentConfigurationTest.java
 
b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/SplunkComponentConfigurationTest.java
index a7cc638..0e217c4 100644
--- 
a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/SplunkComponentConfigurationTest.java
+++ 
b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/SplunkComponentConfigurationTest.java
@@ -52,6 +52,17 @@ public class SplunkComponentConfigurationTest extends 
CamelTestSupport {
     }
 
     @Test
+    public void createProducerWithAnonymousAccess() throws Exception {
+        SplunkComponent component = context.getComponent("splunk", 
SplunkComponent.class);
+        component.setSplunkConfigurationFactory(parameters -> new 
SplunkConfiguration());
+
+        SplunkEndpoint endpoint = (SplunkEndpoint) 
component.createEndpoint("splunk://test");
+        SplunkConnectionFactory scf = 
endpoint.getConfiguration().getConnectionFactory();
+        //following call with fail with "Missing username or password, without 
fix of CAMEL-16313,
+        scf.createService(context);
+    }
+
+    @Test
     public void createProducerEndpointWithMaximalConfiguration() throws 
Exception {
         SplunkComponent component = context.getComponent("splunk", 
SplunkComponent.class);
 

Reply via email to