camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: Fix CS
Date Thu, 30 Mar 2017 08:09:35 GMT
Repository: camel
Updated Branches:
  refs/heads/master 1237f8abc -> 762a2359d


Fix CS


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

Branch: refs/heads/master
Commit: 762a2359daf35abedfb876e215872fe5bd938aeb
Parents: 1237f8a
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Thu Mar 30 10:09:12 2017 +0200
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Thu Mar 30 10:09:12 2017 +0200

----------------------------------------------------------------------
 .../camel/model/OnExceptionDefinition.java       | 19 +++++++++++++------
 .../java/org/apache/camel/util/ObjectHelper.java | 17 +++++++++++++++++
 .../org/apache/camel/util/StringHelperTest.java  |  6 +++---
 .../component/http/HttpProxyConfigurer.java      |  3 ++-
 .../camel/component/http4/HttpComponent.java     |  2 +-
 .../servicenow/ServiceNowExceptionModel.java     | 16 ++++++++++++++++
 .../servicenow/ServiceNowTestSupport.java        |  4 ++--
 .../twitter/CamelComponentVerifierTest.java      |  2 +-
 8 files changed, 55 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java b/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
index 47fbc92..b9bdaaa 100644
--- a/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
@@ -262,12 +262,19 @@ public class OnExceptionDefinition extends ProcessorDefinition<OnExceptionDefini
         // validate that at least some option is set as you cannot just have onException(Exception.class);
         if (outputs == null || getOutputs().isEmpty()) {
             // no outputs so there should be some sort of configuration
-            if (handledPolicy == null && continuedPolicy == null && retryWhilePolicy
== null
-                    && redeliveryPolicyType == null && useOriginalMessagePolicy
== null
-                    && redeliveryPolicy == null && onRedeliveryRef == null
-                    && onRedelivery == null && onExceptionOccurred == null)
{
-                throw new IllegalArgumentException(this + " is not configured.");
-            }
+            ObjectHelper.firstNotNull(
+                    handledPolicy,
+                    continuedPolicy,
+                    retryWhilePolicy,
+                    redeliveryPolicyType,
+                    useOriginalMessagePolicy,
+                    redeliveryPolicy,
+                    onRedeliveryRef,
+                    onRedelivery,
+                    onExceptionOccurred
+                ).orElseThrow(
+                    () -> new IllegalArgumentException(this + " is not configured.")
+                );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
index 3ada9d0..9fcc1ad 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -398,6 +398,23 @@ public final class ObjectHelper {
         }
     }
 
+
+    /**
+     * Returns the first non null object <tt>null</tt>.
+     *
+     * @param values the values
+     * @return an Optional
+     */
+    public static Optional<Object> firstNotNull(Object... values) {
+        for (int i = 0; i < values.length; i++) {
+            if (values[i] != null) {
+                Optional.of(values[i]);
+            }
+        }
+
+        return Optional.empty();
+    }
+
     /**
      * Tests whether the value is <b>not</b> <tt>null</tt>, an empty
string, an empty collection or a map
      *

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
index ca987d8..aa9c37e 100644
--- a/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/StringHelperTest.java
@@ -240,9 +240,9 @@ public class StringHelperTest extends TestCase {
     }
 
     public void testTrimToNull() {
-        assertEquals(StringHelper.trimToNull("abc"),"abc");
-        assertEquals(StringHelper.trimToNull(" abc") , "abc");
-        assertEquals(StringHelper.trimToNull(" abc "),"abc");
+        assertEquals(StringHelper.trimToNull("abc"), "abc");
+        assertEquals(StringHelper.trimToNull(" abc"), "abc");
+        assertEquals(StringHelper.trimToNull(" abc "), "abc");
         assertNull(StringHelper.trimToNull(" "));
         assertNull(StringHelper.trimToNull("\t"));
         assertNull(StringHelper.trimToNull(" \t "));

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProxyConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProxyConfigurer.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProxyConfigurer.java
index ae2bd83..78e99ad 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProxyConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProxyConfigurer.java
@@ -38,7 +38,8 @@ public class HttpProxyConfigurer implements HttpClientConfigurer {
     public void configureHttpClient(HttpClient client) {
         if (proxyHost.isPresent() && proxyPort.isPresent()) {
             client.getHostConfiguration().setProxyHost(new ProxyHost(proxyHost.get(), proxyPort.get()));
-        } if (proxyHost.isPresent()) {
+        } 
+        if (proxyHost.isPresent()) {
             client.getHostConfiguration().setProxyHost(new ProxyHost(proxyHost.get()));
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
index a3eea81..072d6f2 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
@@ -30,8 +30,8 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.ComponentVerifier;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Producer;
-import org.apache.camel.VerifiableComponent;
 import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.VerifiableComponent;
 import org.apache.camel.http.common.HttpBinding;
 import org.apache.camel.http.common.HttpCommonComponent;
 import org.apache.camel.http.common.HttpHelper;

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowExceptionModel.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowExceptionModel.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowExceptionModel.java
index 63c5519..a881d4a 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowExceptionModel.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowExceptionModel.java
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.servicenow;
 
 import java.util.Map;

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java
b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java
index d9cdf49..b3cc5c4 100644
--- a/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java
+++ b/components/camel-servicenow/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java
@@ -31,11 +31,11 @@ class ServiceNowTestSupport extends CamelTestSupport {
 
     private final boolean setUpComponent;
 
-    public ServiceNowTestSupport() {
+    ServiceNowTestSupport() {
         this(true);
     }
 
-    public ServiceNowTestSupport(boolean setUpComponent) {
+    ServiceNowTestSupport(boolean setUpComponent) {
         this.setUpComponent = setUpComponent;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/762a2359/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java
b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java
index 174a2df..4b88158 100644
--- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java
+++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelComponentVerifierTest.java
@@ -97,7 +97,7 @@ public class CamelComponentVerifierTest extends CamelTwitterTestSupport
{
             expected.add("accessToken");
             expected.add("accessTokenSecret");
 
-            for(ComponentVerifier.Error error : result.getErrors()) {
+            for (ComponentVerifier.Error error : result.getErrors()) {
                 expected.removeAll(error.getParameters());
             }
 


Mime
View raw message