Greg Vanore created CAMEL-10600:
-----------------------------------

             Summary: IntrospectionSupport no longer does type conversion on 
references
                 Key: CAMEL-10600
                 URL: https://issues.apache.org/jira/browse/CAMEL-10600
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.18.1
            Reporter: Greg Vanore
            Priority: Minor


I had noticed that {{IntrospectionSupport}} uses the type converter system, so 
was hoping to inject my application config POJOs and then have them converted 
to the appropriate type for certain properties where the configuration is on a 
per-object basis.

My test setup was...

# ... create a route, 
{{from("file://tmp/test?noop=true&idempotentRepository=#foo")}}.
# ... add a bean to my test registry, {{Runnable}} with name {{foo}}.
# ... register a converter that took a {{Runnable}} and just hardcoded a 
{{MemoryIdempotentRepository}} as the result. I know this is strange but I just 
wanted to prove the conversion took place.

Conversion didn't take place, so I set a breakpoint and took a look at 
{{IntrospectionSupport}}. (2.18.1) On lines 531-534, a little bit of logic 
makes sure that the reference is the exact type of the setter, or the setter is 
skipped. This effectively aborts type conversions for references.

I did a casual check through history, looks like this was introduced around 
2.13.0.

The most obvious workaround for this is for us to use a {{CompositeRegistry}} 
and use an established nomenclature (e.g. {{accountName/idempotentRepository}} 
for us to do the fetch and conversion in one spot.

If you deem this a non-feature, it would be nice to at least pass the parameter 
type to the {{CamelContextHelper#lookup}} utility. That way, when we write our 
custom registry, the lookups will supply a type hint (e.g. 
{{lookupByNameAndType}} instead of just {{lookupByName}}. Then we won't be 
forced to come up with a nomenclature that we have to parse, or we could choose 
to make a generic {{TypeConverterRegistry}} that does a lookup by name and then 
a mandatory conversion.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to