davsclaus commented on code in PR #24451:
URL: https://github.com/apache/camel/pull/24451#discussion_r3527853251


##########
core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java:
##########
@@ -95,10 +98,24 @@ public static <T> T property(CamelContext camelContext, 
Class<T> type, Object va
         }
 
         if (value != null) {
-            try {
-                if (MAGIC_VALUE.equals(value) && boolean.class == type) {
-                    value = "true";
+            if (MAGIC_VALUE.equals(value)) {
+                if (boolean.class == type || Boolean.class == type) {
+                    return (T) Boolean.TRUE;
+                } else if (int.class == type || Integer.class == type) {
+                    return (T) Integer.valueOf(1);
+                } else if (long.class == type || Long.class == type) {
+                    return (T) Long.valueOf(1L);
+                } else if (double.class == type || Double.class == type) {
+                    return (T) Double.valueOf(1d);
+                } else if (float.class == type || Float.class == type) {
+                    return (T) Float.valueOf(1f);
+                } else if (short.class == type || Short.class == type) {
+                    return (T) Short.valueOf((short) 1);
+                } else if (byte.class == type || Byte.class == type) {
+                    return (T) Byte.valueOf((byte) 0);
                 }
+            }

Review Comment:
   Please also add `Duration.class` handling here, matching what 
`ExportTypeConverter` does:
   ```suggestion
                   } else if (byte.class == type || Byte.class == type) {
                       return (T) Byte.valueOf((byte) 0);
                   } else if (java.time.Duration.class == type) {
                       return (T) java.time.Duration.ofMillis(1);
                   }
   ```
   And once this is in place, the duplicate MAGIC_VALUE handling in 
`ExportTypeConverter` and `DummyTypeConverter` can be removed.



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