This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 5de926ea4c1 CAMEL-21003: Fix disablement of property location loading when dev profile is active 5de926ea4c1 is described below commit 5de926ea4c1a9922b539505cc779e9687ce04a9f Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Tue Jul 23 11:21:06 2024 +0100 CAMEL-21003: Fix disablement of property location loading when dev profile is active --- .../java/org/apache/camel/main/BaseMainSupport.java | 3 +-- .../camel/main/MainPropertyPlaceholderTest.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java index fb8c24bfeaf..0c7a65ee592 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java @@ -27,7 +27,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Properties; import java.util.Set; @@ -395,7 +394,7 @@ public abstract class BaseMainSupport extends BaseService { if (locations != null) { locations = locations.trim(); } - if (!Objects.equals(locations, "false")) { + if (ObjectHelper.isNotEmpty(locations) && !locations.endsWith("false")) { pc.addLocation(locations); if (defaultPropertyPlaceholderLocation.equals(locations)) { LOG.debug("Properties location: {}", locations); diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java index 5e061d0c5c0..3a01d77fd30 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.parallel.Isolated; import static org.apache.camel.util.CollectionHelper.mapOf; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; @Isolated public class MainPropertyPlaceholderTest { @@ -32,10 +32,19 @@ public class MainPropertyPlaceholderTest { try { main.setDefaultPropertyPlaceholderLocation("false"); main.start(); - main.getCamelContext().resolvePropertyPlaceholders("{{hello}}"); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // ok + assertThrows(IllegalArgumentException.class, () -> main.getCamelContext().resolvePropertyPlaceholders("{{hello}}")); + } finally { + main.stop(); + } + } + + @Test + public void testDefaultPropertyPlaceholderLocationDisabledWithAdditionalLocations() { + Main main = new Main(); + try { + main.setDefaultPropertyPlaceholderLocation("classpath:additional-config.properties,false"); + main.start(); + assertThrows(IllegalArgumentException.class, () -> main.getCamelContext().resolvePropertyPlaceholders("{{hello}}")); } finally { main.stop(); }