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


##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/AbstractEarlyResolutionPropertiesParser.java:
##########
@@ -105,8 +104,12 @@ public final void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event)
         for (PropertySource<?> propertySource : 
environment.getPropertySources()) {
             if (propertySource instanceof MapPropertySource mapPropertySource) 
{

Review Comment:
   **Addressed:** Precedence logic in AbstractEarlyResolutionPropertiesParser 
after #1917 rebase.



##########
core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/AbstractEarlyResolutionPropertiesParserTest.java:
##########
@@ -309,4 +309,42 @@ public void ignoreResolutionFailuresKeepsStartupGoing() {
         assertEquals("{{test:missing}}", environment.getProperty("bad.secret"),
                 "in tolerant mode the unresolved placeholder is deliberately 
left in place");
     }
+
+    @Test

Review Comment:
   **Addressed:** Parser-level regression test for duplicate placeholders — 
highest precedence wins, lower not resolved.



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/EarlyResolutionPropertySources.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot;
+
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.springframework.boot.origin.OriginTrackedValue;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.PropertySource;
+
+/**
+ * Helpers for early property resolution listeners that inject a flat {@link 
Properties} override via
+ * {@code PropertySources.addFirst}.
+ * <p/>
+ * Spring iterates property sources in precedence order (highest first). When 
the same key appears in multiple
+ * sources, callers must retain the first resolved value so the override map 
reflects Spring's normal precedence
+ * after it is added with {@code addFirst}.
+ */
+public final class EarlyResolutionPropertySources {
+
+    private EarlyResolutionPropertySources() {
+    }
+
+    /**
+     * Returns the string value from a property source entry, including {@link 
OriginTrackedValue} wrappers.
+     */
+    public static String asString(Object value) {
+        if (value instanceof OriginTrackedValue originTrackedValue
+                && originTrackedValue.getValue() instanceof String 
stringValue) {
+            return stringValue;
+        }
+        if (value instanceof String stringValue) {
+            return stringValue;
+        }
+        return null;
+    }
+
+    /**
+     * Stores a resolved value only when the key is not already present, 
preserving highest-precedence values
+     * collected while iterating property sources.
+     */
+    public static void putIfAbsent(Properties props, Object key, String 
resolvedValue) {
+        props.putIfAbsent(key.toString(), resolvedValue);
+    }
+
+    /**
+     * Returns whether a property source with higher precedence defines the 
same key.
+     * <p/>
+     * Only {@link MapPropertySource} instances are inspected, matching the 
scanning loop used by the early-resolution

Review Comment:
   **Addressed:** Documented MapPropertySource-only limitation in 
hasHigherPrecedenceProperty javadoc.



##########
components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/SpringBootJasyptPropertiesParser.java:
##########
@@ -74,10 +75,15 @@ public void 
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                                 originTrackedValue.getValue() instanceof 
String stringValue &&
                                 
stringValue.startsWith(JasyptPropertiesParser.JASYPT_PREFIX_TOKEN) &&
                                 
stringValue.endsWith(JasyptPropertiesParser.JASYPT_SUFFIX_TOKEN)) {

Review Comment:
   **Addressed:** Jasypt keeps OriginTrackedValue-only matching; added 
precedence guard + putIfAbsent only.



-- 
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