Skip to content

Commit 28a9264

Browse files
committed
Align PropertiesComponent defaults value to Camel's ones
1 parent ea85081 commit 28a9264

4 files changed

Lines changed: 28 additions & 8 deletions

File tree

core/camel-spring-boot/src/main/docs/spring-boot.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@
390390
"name": "camel.component.properties.environment-variable-mode",
391391
"type": "java.lang.Integer",
392392
"description": "Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use OS environment variables if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode",
393-
"sourceType": "org.apache.camel.spring.boot.PropertiesComponentConfiguration",
394-
"defaultValue": 2
393+
"sourceType": "org.apache.camel.spring.boot.PropertiesComponentConfiguration"
395394
},
396395
{
397396
"name": "camel.component.properties.ignore-missing-location",
@@ -417,7 +416,7 @@
417416
"type": "java.lang.Boolean",
418417
"description": "Whether to support nested property placeholders. A nested placeholder, means that a placeholder, has also a placeholder, that should be resolved (recursively).",
419418
"sourceType": "org.apache.camel.spring.boot.PropertiesComponentConfiguration",
420-
"defaultValue": false
419+
"defaultValue": true
421420
},
422421
{
423422
"name": "camel.component.properties.override-properties",
@@ -435,8 +434,7 @@
435434
"name": "camel.component.properties.system-properties-mode",
436435
"type": "java.lang.Integer",
437436
"description": "Sets the JVM system property mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use system properties if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode",
438-
"sourceType": "org.apache.camel.spring.boot.PropertiesComponentConfiguration",
439-
"defaultValue": 2
437+
"sourceType": "org.apache.camel.spring.boot.PropertiesComponentConfiguration"
440438
},
441439
{
442440
"name": "camel.dataformat.customizer.enabled",

core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/PropertiesComponentConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.camel.spring.boot;
1818

19+
import org.apache.camel.component.properties.PropertiesComponent;
1920
import org.springframework.boot.context.properties.ConfigurationProperties;
2021

2122
/**
@@ -51,7 +52,7 @@ public class PropertiesComponentConfiguration {
5152
* Whether to support nested property placeholders. A nested placeholder, means that a placeholder, has also a
5253
* placeholder, that should be resolved (recursively).
5354
*/
54-
private Boolean nestedPlaceholder = false;
55+
private Boolean nestedPlaceholder = true;
5556
/**
5657
* Sets initial properties which will be used before any locations are resolved. The option is a
5758
* java.util.Properties type.
@@ -67,13 +68,13 @@ public class PropertiesComponentConfiguration {
6768
* system properties if present, and override any existing properties. OS environment variable mode is checked
6869
* before JVM system property mode
6970
*/
70-
private Integer systemPropertiesMode = 2;
71+
private Integer systemPropertiesMode = PropertiesComponent.SYSTEM_PROPERTIES_MODE_OVERRIDE;
7172
/**
7273
* Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to
7374
* use OS environment variables if present, and override any existing properties. OS environment variable mode is
7475
* checked before JVM system property mode
7576
*/
76-
private Integer environmentVariableMode = 2;
77+
private Integer environmentVariableMode = PropertiesComponent.ENVIRONMENT_VARIABLES_MODE_OVERRIDE;
7778
/**
7879
* Whether to automatically discovery instances of PropertiesSource from registry and service factory.
7980
*/

core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationPropertiesTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class CamelAutoConfigurationPropertiesTest {
4242
@Value("${from}")
4343
String from;
4444

45+
@Value("${from}-nested")
46+
String fromNested;
47+
4548
// Collaborators fixtures
4649

4750
@Autowired
@@ -64,6 +67,8 @@ RouteBuilder routeBuilder() {
6467
@Override
6568
public void configure() throws Exception {
6669
from(from).to("{{to}}");
70+
71+
from("direct:test-nested").to("{{nested.to}}");
6772
}
6873
};
6974
}
@@ -76,6 +81,7 @@ public void shouldResolveBothCamelAndSpringPlaceholders() throws InterruptedExce
7681
// Given
7782
MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:test", MockEndpoint.class);
7883
mockEndpoint.expectedMessageCount(1);
84+
mockEndpoint.reset();
7985

8086
// When
8187
producerTemplate.sendBody(from, "msg");
@@ -84,4 +90,18 @@ public void shouldResolveBothCamelAndSpringPlaceholders() throws InterruptedExce
8490
mockEndpoint.assertIsSatisfied();
8591
}
8692

93+
@Test
94+
public void shouldResolveNestedCamelPlaceholder() throws InterruptedException {
95+
// Given
96+
MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:test", MockEndpoint.class);
97+
mockEndpoint.expectedMessageCount(1);
98+
mockEndpoint.reset();
99+
100+
// When
101+
producerTemplate.sendBody(fromNested, "msg");
102+
103+
// Then
104+
mockEndpoint.assertIsSatisfied();
105+
}
106+
87107
}

core/camel-spring-boot/src/test/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ spring.main.banner-mode=off
1919

2020
from=direct:test
2121
to=mock:test
22+
nested.to={{to}}
2223

2324
#logging.level.org.apache.camel=DEBUG

0 commit comments

Comments
 (0)