You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/10/26 19:15:18 UTC

[camel] branch main updated: CAMEL-20051: do cache fallback conversions (#11846)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7c104aaaff9 CAMEL-20051: do cache fallback conversions (#11846)
7c104aaaff9 is described below

commit 7c104aaaff93a930cb2b26bb85ae848d9e8d2af3
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Oct 26 21:15:11 2023 +0200

    CAMEL-20051: do cache fallback conversions (#11846)
---
 .../org/apache/camel/impl/converter/CoreTypeConverterRegistry.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterRegistry.java b/core/camel-base/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterRegistry.java
index 17a4a8425f1..8d0f0ad0a06 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterRegistry.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterRegistry.java
@@ -381,7 +381,7 @@ public abstract class CoreTypeConverterRegistry extends ServiceSupport implement
         }
 
         // fallback converters
-        final Object fallBackRet = tryFallback(type, exchange, value, tryConvert);
+        final Object fallBackRet = tryFallback(type, exchange, value, tryConvert, typeConvertible);
         if (fallBackRet != null) {
             return fallBackRet;
         }
@@ -426,7 +426,9 @@ public abstract class CoreTypeConverterRegistry extends ServiceSupport implement
         return null;
     }
 
-    private Object tryFallback(final Class<?> type, final Exchange exchange, final Object value, boolean tryConvert) {
+    private Object tryFallback(
+            final Class<?> type, final Exchange exchange, final Object value, boolean tryConvert,
+            TypeConvertible<?, ?> typeConvertible) {
         for (FallbackTypeConverter fallback : fallbackConverters) {
             TypeConverter tc = fallback.getFallbackTypeConverter();
 
@@ -441,6 +443,7 @@ public abstract class CoreTypeConverterRegistry extends ServiceSupport implement
             }
 
             if (rc != null) {
+                converters.put(typeConvertible, tc);
                 // if fallback can promote then let it be promoted to a first class type converter
                 if (fallback.isCanPromote()) {
                     // add it as a known type converter since we found a fallback that could do it