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 a2a252a9c188028ea95d310249d699ab12bcdbaf
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Jun 28 05:53:50 2019 +0200

    Fixed CS
---
 .../org/apache/camel/PropertyBindingException.java | 30 ++++++++++++++--------
 .../java/org/apache/camel/main/MainSupport.java    |  8 +++---
 .../camel/support/PropertyBindingSupport.java      |  2 +-
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git 
a/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java 
b/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java
index 377b718..315c53e 100644
--- 
a/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java
+++ 
b/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java
@@ -24,27 +24,42 @@ public class PropertyBindingException extends 
RuntimeCamelException {
     private final Object target;
     private final String propertyName;
     private final Object value;
-    private String optionPrefix;
-    private String optionKey;
+    private final String optionPrefix;
+    private final String optionKey;
 
     public PropertyBindingException(Object target, String propertyName, Object 
value) {
         this.target = target;
         this.propertyName = propertyName;
         this.value = value;
+        this.optionPrefix = null;
+        this.optionKey = null;
     }
 
-    public PropertyBindingException(Object target, String propertyName, Object 
value, Exception e) {
+    public PropertyBindingException(Object target, String propertyName, Object 
value, Throwable e) {
         initCause(e);
         this.target = target;
         this.propertyName = propertyName;
         this.value = value;
+        this.optionPrefix = null;
+        this.optionKey = null;
     }
 
-    public PropertyBindingException(Object target, Exception e) {
+    public PropertyBindingException(Object target, Throwable e) {
         initCause(e);
         this.target = target;
         this.propertyName = null;
         this.value = null;
+        this.optionPrefix = null;
+        this.optionKey = null;
+    }
+
+    public PropertyBindingException(Object target, String propertyName, Object 
value, String optionPrefix, String optionKey, Throwable e) {
+        initCause(e);
+        this.target = target;
+        this.propertyName = propertyName;
+        this.value = value;
+        this.optionPrefix = optionPrefix;
+        this.optionKey = optionKey;
     }
 
     @Override
@@ -78,15 +93,8 @@ public class PropertyBindingException extends 
RuntimeCamelException {
         return optionPrefix;
     }
 
-    public void setOptionPrefix(String optionPrefix) {
-        this.optionPrefix = optionPrefix;
-    }
-
     public String getOptionKey() {
         return optionKey;
     }
 
-    public void setOptionKey(String optionKey) {
-        this.optionKey = optionKey;
-    }
 }
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index 57be0f3..cb2f182 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -1003,7 +1003,7 @@ public abstract class MainSupport extends ServiceSupport {
 
         if (!properties.isEmpty()) {
             LOG.info("Auto configuring main from loaded properties: {}", 
properties.size());
-            setPropertiesOnTarget(camelContext, config, properties, 
null,"camel.main.",
+            setPropertiesOnTarget(camelContext, config, properties, null, 
"camel.main.",
                     mainConfigurationProperties.isAutoConfigurationFailFast(), 
true);
         }
 
@@ -1242,10 +1242,8 @@ public abstract class MainSupport extends ServiceSupport 
{
                 }
             } catch (PropertyBindingException e) {
                 if (failIfNotSet) {
-                    // enrich the error with better details
-                    e.setOptionPrefix(optionPrefix);
-                    e.setOptionKey(optionKey);
-                    throw e;
+                    // enrich the error with more precise details with option 
prefix and key
+                    throw new PropertyBindingException(e.getTarget(), 
e.getPropertyName(), e.getValue(), optionPrefix, optionKey, e.getCause());
                 } else {
                     LOG.debug("Error setting property (" + key + ") with name: 
" + name + ") on bean: " + target
                             + " with value: " + stringValue + ". This 
exception is ignored as failIfNotSet=false.", e);
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 975fea8..310042f 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -470,7 +470,7 @@ public final class PropertyBindingSupport {
      * @param ignoreCase    whether to ignore case for property keys
      * @throws PropertyBindingException is thrown if error binding property, 
or the property was not bound
      */
-    public static void bindMandatoryProperty(CamelContext camelContext, Object 
target, String name, Object value, boolean ignoreCase) throws 
PropertyBindingException{
+    public static void bindMandatoryProperty(CamelContext camelContext, Object 
target, String name, Object value, boolean ignoreCase) throws 
PropertyBindingException {
         boolean bound;
         if (target != null && name != null) {
             try {

Reply via email to