gnodet-bot commented on code in PR #30398:
URL: https://github.com/apache/camel/pull/30398#discussion_r4628815745


##########
core/camel-support/src/main/java/org/apache/camel/support/NormalizedUri.java:
##########
@@ -40,13 +50,41 @@ private NormalizedUri(String value) {
      * @return            the created normalized uri
      */
     public static NormalizedUri newNormalizedUri(String uri, boolean 
normalized) {
+        return newNormalizedUri(uri, normalized, false);
+    }
+
+    /**
+     * Creates a new {@link NormalizedUri} instance.
+     *
+     * @param  uri                  the uri
+     * @param  normalized           whether its already normalized
+     * @param  literalOptionBinding whether the uri was computed from the 
current message, so its option values are
+     *                              bound as literal text: no property 
placeholders, {@code #class:} or
+     *                              {@code #property:}; registry references 
({@code #bean:}, {@code #type:}) are still
+     *                              resolved
+     * @return                      the created normalized uri
+     * @since                       4.24

Review Comment:
   🐛 **Wrong `@since` version for backport branch.** This method is being added 
to `camel-4.18.x` and will first be available in 4.18.6, not 4.24.
   
   ```suggestion
        * @since                       4.18.6
   ```



##########
core/camel-support/src/main/java/org/apache/camel/support/NormalizedUri.java:
##########
@@ -40,13 +50,41 @@ private NormalizedUri(String value) {
      * @return            the created normalized uri
      */
     public static NormalizedUri newNormalizedUri(String uri, boolean 
normalized) {
+        return newNormalizedUri(uri, normalized, false);
+    }
+
+    /**
+     * Creates a new {@link NormalizedUri} instance.
+     *
+     * @param  uri                  the uri
+     * @param  normalized           whether its already normalized
+     * @param  literalOptionBinding whether the uri was computed from the 
current message, so its option values are
+     *                              bound as literal text: no property 
placeholders, {@code #class:} or
+     *                              {@code #property:}; registry references 
({@code #bean:}, {@code #type:}) are still
+     *                              resolved
+     * @return                      the created normalized uri
+     * @since                       4.24
+     */
+    public static NormalizedUri newNormalizedUri(String uri, boolean 
normalized, boolean literalOptionBinding) {
         if (normalized) {
-            return new NormalizedUri(uri);
+            return new NormalizedUri(uri, literalOptionBinding);
         } else {
-            return new NormalizedUri(EndpointHelper.normalizeEndpointUri(uri));
+            return new NormalizedUri(EndpointHelper.normalizeEndpointUri(uri), 
literalOptionBinding);
         }
     }
 
+    /**
+     * Whether this uri was computed from the current message at runtime, so 
the option values of the endpoint created
+     * from it are bound as literal text: a property placeholder ({@code 
{{...}}}), a {@code #class:} value or a
+     * {@code #property:} value is not resolved. Registry references ({@code 
#bean:}, {@code #type:}) are still
+     * resolved.
+     *
+     * @since 4.24

Review Comment:
   🐛 **Wrong `@since` version.** Same as above — `4.18.6` on this branch.
   
   ```suggestion
        * @since 4.18.6
   ```



##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java:
##########
@@ -111,10 +111,77 @@ public final class PropertyBindingSupport {
     private PropertyBindingSupport() {
     }
 
+    // a thread-scoped signal that the endpoint currently being created has a 
uri computed from the current message at
+    // runtime (a dynamic endpoint such as 
toD/enrich/wireTap/pollEnrich/recipientList/routingSlip/dynamicRouter), so
+    // its option values are bound as literal text. The CamelContext sets it 
(in a try/finally) around
+    // Component#createEndpoint(String, Map) only. While it is set, the 
Builder binds in literal mode, and resolveBean
+    // and EndpointHelper#resolveReferenceParameter refuse the values that are 
kept literal, so every way a component
+    // binds its options is covered (generated configurers, setProperties 
overloads, resolveAndRemoveReferenceParameter
+    // and direct use of this class).
+    private static final ThreadLocal<Boolean> LITERAL_OPTION_BINDING = new 
ThreadLocal<>();
+
     public static Builder build() {
         return new Builder();
     }
 
+    /**
+     * Whether the endpoint currently being created on this thread binds its 
option values as literal text, because its
+     * uri was computed from the current message at runtime, see {@link 
Builder#withLiteral(boolean)}.
+     *
+     * @return true if literal option binding is active on the current thread
+     * @since  4.24

Review Comment:
   🐛 **Wrong `@since` version.** This is `camel-4.18.x` — the method first 
ships in 4.18.6.
   
   ```suggestion
        * @since  4.18.6
   ```



##########
core/camel-support/src/main/java/org/apache/camel/support/component/RawParameterHelper.java:
##########
@@ -36,12 +37,37 @@ private RawParameterHelper() {
      * The value can refer to a simple expression using $simple{xxx} syntax 
which allows to refer to passwords defined
      * as ENV variables etc.
      *
+     * When the endpoint currently being created on this thread binds its 
option values as literal text (see
+     * {@link PropertyBindingSupport#isLiteralOptionBinding()}), the RAW 
tokens are removed but a $simple{xxx} in the
+     * value is not evaluated, see {@link 
#resolveRawParameterValues(CamelContext, Map, boolean)}.
+     *
      * @param camelContext the camel context
      * @param parameters   the uri parameters
      */
     public static void resolveRawParameterValues(CamelContext camelContext, 
Map<String, Object> parameters) {
+        resolveRawParameterValues(camelContext, parameters, 
PropertyBindingSupport.isLiteralOptionBinding());
+    }
+
+    /**
+     * Traverses the given parameters, and resolves any parameter values which 
use the RAW token syntax:
+     * <code>key=RAW(value)</code>. This method will then remove the RAW 
tokens, and replace the content of the value,
+     * with just the value.
+     *
+     * When {@code literal} is {@code false} the value can refer to a simple 
expression using $simple{xxx} syntax which
+     * allows to refer to passwords defined as ENV variables etc. When {@code 
literal} is {@code true} the value is
+     * taken as literal text and a $simple{xxx} in it is not evaluated. This 
is used for an endpoint whose uri was
+     * computed from the current message at runtime (for example the 
per-message recipient of {@code toD} or
+     * {@code pollEnrich}), as its option values come from the message and not 
from the route.
+     *
+     * @param camelContext the camel context
+     * @param parameters   the uri parameters
+     * @param literal      whether the RAW values are taken as literal text, 
without evaluating $simple{xxx}
+     * @since              4.24

Review Comment:
   🐛 **Wrong `@since` version.** `4.18.6` on this branch.
   
   ```suggestion
        * @since              4.18.6
   ```



##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java:
##########
@@ -1874,6 +1973,23 @@ public Builder withPlaceholder(boolean placeholder) {
             return this;
         }
 
+        /**
+         * Whether to bind in literal mode, for values computed from message 
content at runtime (for example the option
+         * values of a dynamic endpoint). In literal mode a value with a 
property placeholder ({@code {{...}}}), a
+         * {@code #class:} value or a {@code #property:} value is bound as 
literal text, and option names are not
+         * resolved as property placeholders. Plain registry references 
({@code #bean:}, {@code #type:}, {@code #name})
+         * are still resolved.
+         * <p>
+         * Literal mode is also on, whatever this option says, while a literal 
option binding scope is active on the
+         * current thread, see {@link 
PropertyBindingSupport#isLiteralOptionBinding()}.
+         *
+         * @since 4.24

Review Comment:
   🐛 **Wrong `@since` version.** `4.18.6` on this branch.
   
   ```suggestion
            * @since 4.18.6
   ```



##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java:
##########
@@ -111,10 +111,77 @@ public final class PropertyBindingSupport {
     private PropertyBindingSupport() {
     }
 
+    // a thread-scoped signal that the endpoint currently being created has a 
uri computed from the current message at
+    // runtime (a dynamic endpoint such as 
toD/enrich/wireTap/pollEnrich/recipientList/routingSlip/dynamicRouter), so
+    // its option values are bound as literal text. The CamelContext sets it 
(in a try/finally) around
+    // Component#createEndpoint(String, Map) only. While it is set, the 
Builder binds in literal mode, and resolveBean
+    // and EndpointHelper#resolveReferenceParameter refuse the values that are 
kept literal, so every way a component
+    // binds its options is covered (generated configurers, setProperties 
overloads, resolveAndRemoveReferenceParameter
+    // and direct use of this class).
+    private static final ThreadLocal<Boolean> LITERAL_OPTION_BINDING = new 
ThreadLocal<>();
+
     public static Builder build() {
         return new Builder();
     }
 
+    /**
+     * Whether the endpoint currently being created on this thread binds its 
option values as literal text, because its
+     * uri was computed from the current message at runtime, see {@link 
Builder#withLiteral(boolean)}.
+     *
+     * @return true if literal option binding is active on the current thread
+     * @since  4.24
+     */
+    public static boolean isLiteralOptionBinding() {
+        return Boolean.TRUE.equals(LITERAL_OPTION_BINDING.get());
+    }
+
+    /**
+     * Marks (or clears) the current thread as creating an endpoint whose 
option values are bound as literal text. The
+     * caller MUST restore the returned previous value in a {@code finally} 
block. The CamelContext does this around
+     * {@link org.apache.camel.Component#createEndpoint(String, Map)} when the 
uri was computed from the current
+     * message.
+     *
+     * @param  literalOptionBinding whether literal option binding is active
+     * @return                      the previous value, to be restored by the 
caller
+     * @since                       4.24

Review Comment:
   🐛 **Wrong `@since` version.** `4.18.6` on this branch.
   
   ```suggestion
        * @since                       4.18.6
   ```



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