Croway commented on code in PR #1907:
URL: 
https://github.com/apache/camel-spring-boot/pull/1907#discussion_r3880625937


##########
components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SpringBootAwsSecretsManagerPropertiesParser.java:
##########
@@ -92,7 +86,7 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                         .replace("{{aws:", "")
                                         .replace("}}", ""));
-                                props.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
   
                           if (stringValue != null &&
                                   stringValue.startsWith("{{aws:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                           .replace("{{aws:", "")
                                           .replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, element);
   ```



##########
components-starter/camel-azure-key-vault-starter/src/main/java/org/apache/camel/component/azure/key/vault/springboot/SpringBootAzureKeyVaultPropertiesParser.java:
##########
@@ -101,7 +95,7 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 String element = 
keyVaultPropertiesFunction.apply(stringValue
                                         .replace("{{azure:", "")
                                         .replace("}}", ""));
-                                props.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
                           if (stringValue != null &&
                                   stringValue.startsWith("{{azure:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
keyVaultPropertiesFunction.apply(stringValue
                                           .replace("{{azure:", "")
                                           .replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, element);
   ```



##########
components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/SpringBootCyberArkVaultPropertiesParser.java:
##########
@@ -90,7 +84,7 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 String element = 
cyberArkVaultPropertiesFunction.apply(stringValue
                                         .replace("{{cyberark:", "")
                                         .replace("}}", ""));
-                                props.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
   
                           if (stringValue != null &&
                                   stringValue.startsWith("{{cyberark:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
cyberArkVaultPropertiesFunction.apply(stringValue
                                           .replace("{{cyberark:", "")
                                           .replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, element);
   ```



##########
components-starter/camel-google-secret-manager-starter/src/main/java/org/apache/camel/component/google/secret/manager/springboot/SpringBootGoogleSecretManagerPropertiesParser.java:
##########
@@ -77,7 +71,7 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                         .replace("{{gcp:", "")
                                         .replace("}}", ""));
-                                props.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
                           if (stringValue != null &&
                                   stringValue.startsWith("{{gcp:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                           .replace("{{gcp:", "")
                                           .replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, element);
   ```



##########
components-starter/camel-hashicorp-vault-starter/src/main/java/org/apache/camel/component/hashicorp/vault/springboot/SpringBootHashicorpVaultPropertiesParser.java:
##########
@@ -65,20 +65,14 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
             for (PropertySource mutablePropertySources : 
event.getEnvironment().getPropertySources()) {
                 if (mutablePropertySources instanceof MapPropertySource 
mapPropertySource) {
                     mapPropertySource.getSource().forEach((key, value) -> {
-                        String stringValue = null;
-                        if ((value instanceof OriginTrackedValue 
originTrackedValue &&
-                                originTrackedValue.getValue() instanceof 
String v)) {
-                            stringValue = v;
-                        } else if (value instanceof String v) {
-                            stringValue = v;
-                        }
+                        String stringValue = 
EarlyResolutionPropertySources.asString(value);
 
                         if (stringValue != null &&
                                 stringValue.startsWith("{{hashicorp:") &&
                                 stringValue.endsWith("}}")) {
                             LOG.debug("decrypting and overriding property {}", 
key);
                             try {
-                                props.put(key, 
hashicorpVaultPropertiesFunction.apply(stringValue
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, 
hashicorpVaultPropertiesFunction.apply(stringValue

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
   
                           if (stringValue != null &&
                                   stringValue.startsWith("{{hashicorp:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, 
hashicorpVaultPropertiesFunction.apply(stringValue
   ```



##########
components-starter/camel-ibm-secrets-manager-starter/src/main/java/org/apache/camel/component/ibm/secrets/manager/springboot/IBMSecretsManagerVaultPropertiesParser.java:
##########
@@ -75,7 +69,7 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                         .replace("{{ibm:", "")
                                         .replace("}}", ""));
-                                props.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
                           if (stringValue != null &&
                                   stringValue.startsWith("{{ibm:") &&
                                   stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
secretsManagerPropertiesFunction.apply(stringValue
                                           .replace("{{ibm:", "")
                                           .replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key, element);
   ```



##########
components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/SpringBootJasyptPropertiesParser.java:
##########
@@ -70,14 +70,15 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
             for (PropertySource mutablePropertySources : 
event.getEnvironment().getPropertySources()) {
                 if (mutablePropertySources instanceof MapPropertySource 
mapPropertySource) {
                     mapPropertySource.getSource().forEach((key, value) -> {
-                        if (value instanceof OriginTrackedValue 
originTrackedValue &&
-                                originTrackedValue.getValue() instanceof 
String stringValue &&
-                                
stringValue.startsWith(JasyptPropertiesParser.JASYPT_PREFIX_TOKEN) &&
-                                
stringValue.endsWith(JasyptPropertiesParser.JASYPT_SUFFIX_TOKEN)) {
+                        String stringValue = 
EarlyResolutionPropertySources.asString(value);
+                        if (stringValue != null
+                                && 
stringValue.startsWith(JasyptPropertiesParser.JASYPT_PREFIX_TOKEN)
+                                && 
stringValue.endsWith(JasyptPropertiesParser.JASYPT_SUFFIX_TOKEN)) {
 
                             LOG.debug("decrypting and overriding property {}", 
key);
                             try {
-                                props.put(key, 
propertiesParser.parseProperty(key.toString(), stringValue, null));
+                                
EarlyResolutionPropertySources.putIfAbsent(props, key,

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
                           if (stringValue != null
                                   && 
stringValue.startsWith(JasyptPropertiesParser.JASYPT_PREFIX_TOKEN)
                                   && 
stringValue.endsWith(JasyptPropertiesParser.JASYPT_SUFFIX_TOKEN)) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
   
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   
EarlyResolutionPropertySources.putIfAbsent(props, key,
   ```



##########
components-starter/camel-spring-cloud-config-starter/src/main/java/org/apache/camel/component/spring/cloud/config/springboot/SpringBootCloudConfigPropertiesParser.java:
##########
@@ -44,20 +44,14 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
             for (PropertySource mutablePropertySources : 
event.getEnvironment().getPropertySources()) {
                 if (mutablePropertySources instanceof MapPropertySource 
mapPropertySource) {
                     mapPropertySource.getSource().forEach((key, value) -> {
-                        String stringValue = null;
-                        if ((value instanceof OriginTrackedValue 
originTrackedValue
-                                && originTrackedValue.getValue() instanceof 
String v)) {
-                            stringValue = v;
-                        } else if (value instanceof String v) {
-                            stringValue = v;
-                        }
+                        String stringValue = 
EarlyResolutionPropertySources.asString(value);
                         if (stringValue != null && 
stringValue.startsWith("{{spring-config:")
                                 && stringValue.endsWith("}}")) {
                             LOG.debug("decrypting and overriding property {}", 
key);
                             try {
                                 String element = 
springCloudConfigPropertiesFunction
                                         
.apply(stringValue.replace("{{spring-config:", "").replace("}}", ""));
-                                properties.put(key, element);
+                                
EarlyResolutionPropertySources.putIfAbsent(properties, key, element);

Review Comment:
   ```suggestion
                           String stringValue = 
EarlyResolutionPropertySources.asString(value);
                           if (stringValue != null && 
stringValue.startsWith("{{spring-config:")
                                   && stringValue.endsWith("}}")) {
                               if 
(EarlyResolutionPropertySources.hasHigherPrecedenceProperty(
                                       
event.getEnvironment().getPropertySources(), mutablePropertySources, key)) {
                                   LOG.debug(
                                           "Skipping early resolution for 
property {} from property source {} because a "
                                                   + "higher-precedence 
property source already defines it",
                                           key, 
mutablePropertySources.getName());
                                   return;
                               }
                               LOG.debug("decrypting and overriding property 
{}", key);
                               try {
                                   String element = 
springCloudConfigPropertiesFunction
                                           
.apply(stringValue.replace("{{spring-config:", "").replace("}}", ""));
                                   
EarlyResolutionPropertySources.putIfAbsent(properties, key, element);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to