This is an automated email from the ASF dual-hosted git repository. valdar 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 6eb34d4 Fix CAMEL-14534: Wrong message in some cases in org.apache.camel.PropertyBindingException. new 1411128 Merge pull request #3569 from valdar/CAMEL-14534 6eb34d4 is described below commit 6eb34d4a70fd5a759d5fc7953bef994f2e60de02 Author: Andrea Tarocchi <andrea.taroc...@gmail.com> AuthorDate: Tue Feb 11 16:13:55 2020 +0100 Fix CAMEL-14534: Wrong message in some cases in org.apache.camel.PropertyBindingException. --- .../org/apache/camel/PropertyBindingException.java | 2 +- .../apache/camel/PropertyBindingExceptionTest.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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 315c53e..426193a 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 @@ -67,7 +67,7 @@ public class PropertyBindingException extends RuntimeCamelException { String stringValue = value != null ? value.toString() : ""; String key = propertyName; if (optionPrefix != null && optionKey != null) { - key = optionPrefix + "." + optionKey; + key = optionPrefix.endsWith(".") ? optionPrefix + optionKey : optionPrefix + "." + optionKey; } if (key != null) { return "Error binding property (" + key + "=" + stringValue + ") with name: " + propertyName diff --git a/core/camel-core/src/test/java/org/apache/camel/PropertyBindingExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/PropertyBindingExceptionTest.java new file mode 100644 index 0000000..8d37303 --- /dev/null +++ b/core/camel-core/src/test/java/org/apache/camel/PropertyBindingExceptionTest.java @@ -0,0 +1,20 @@ +package org.apache.camel; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class PropertyBindingExceptionTest { + public static final String EXPECTED_EXCEPTION_MESSAGE = "Error binding property (prefix.property=value) with name: property"; + + @Test + public void exceptionMessageTest(){ + PropertyBindingException pbe = new PropertyBindingException(new Object(), "property", "value", "prefix", "property", new Throwable("The casue!")); + assertTrue("PropertyBindingException message should start with [" + EXPECTED_EXCEPTION_MESSAGE + "] while is [" + pbe.getMessage() + "] instead.", + pbe.getMessage().startsWith(EXPECTED_EXCEPTION_MESSAGE)); + + pbe = new PropertyBindingException(new Object(), "property", "value", "prefix.", "property", new Throwable("The casue!")); + assertTrue("PropertyBindingException message should start with [" + EXPECTED_EXCEPTION_MESSAGE + "] while is [" + pbe.getMessage() + "] instead.", + pbe.getMessage().startsWith(EXPECTED_EXCEPTION_MESSAGE)); + } +}