[ 
https://issues.apache.org/jira/browse/CAMEL-21546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17905504#comment-17905504
 ] 

Artem St commented on CAMEL-21546:
----------------------------------

[~davsclaus] , Thank you for your reply. I understand that after the 
attachments were refactored, I should use the Attachments API directly. 
However, my concern is more about backward compatibility. We have numerous 
routes with similar code from older versions of Camel. If I understand 
correctly, {{safeCopyProperties}} could potentially be used not just for 
attachments but also for other properties, either now or in the future.

> camel-core - simple expressions like 
> ${exchangeProperty.CamelAttachmentObjects} does not working because 
> AbstractExchange.getProperty does not fallback to a safeCopyProperties 
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-21546
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21546
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 3.22.2, 4.9.0
>            Reporter: Artem St
>            Priority: Minor
>
> I'm not sure if this is a bug or intended behavior, but when we search for 
> properties on an exchange, the search only checks the {{internalProperties}} 
> of the exchange and the {{properties}} map. It does not look into 
> {{{}safeCopyProperties{}}}.
> As a result, simple code like this stopped working after the attachments were 
> refactored:
> {code:java}
>  ${exchangeProperty.CamelAttachmentObjects}{code}
>  
> The current implementation of {{getProperty}} is as follows:
> {code:java}
>     @Override
>     public Object getProperty(String name) {
>         Object answer = null;
>         ExchangePropertyKey key = 
> ExchangePropertyKey.asExchangePropertyKey(name);
>         if (key != null) {
>             answer = internalProperties.get(key);
>             // if the property is not an internal then fallback to lookup in 
> the properties map
>         }
>         if (answer == null && properties != null) {
>             answer = properties.get(name);
>         }
>         return answer;
>     } {code}
>  
> Shouldn't it be more like this to include {{safeCopyProperties}} in the 
> lookup?
> {code:java}
>     public Object getProperty(String name) {
>         Object answer = null;
>         ExchangePropertyKey key = 
> ExchangePropertyKey.asExchangePropertyKey(name);
>         if (key != null) {
>             answer = internalProperties[key.ordinal()];
>             // if the property is not an internal then fallback to lookup in 
> the properties map
>         }
>         if (answer == null && hasSafeCopyProperties()) {
>             answer = safeCopyProperties.get(name);
>         }
>         if (answer == null && properties != null) {
>             answer = properties.get(name);
>         }
>         return answer;
>     } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to