You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Antoine DESSAIGNE (JIRA)" <ji...@apache.org> on 2019/07/09 13:58:00 UTC
[jira] [Updated] (CAMEL-13741) Map to Iterable converter regression
[ https://issues.apache.org/jira/browse/CAMEL-13741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antoine DESSAIGNE updated CAMEL-13741:
--------------------------------------
Description:
When converting a {{Map}} to an {{Iterable}} the results is no longer the same since CAMEL-11379.
Given the following context
{code}
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer:single?repeatCount=1"/>
<setBody>
<groovy>[A: 'aa', B: 'bb', C: 'cc', D: 'dd']</groovy>
</setBody>
<convertBodyTo type="java.lang.Iterable"/>
<split>
<simple>${body}</simple>
<log message="${body}"/>
</split>
</route>
</routes>
{code}
It produces 4 log messages in camel 2.18.3 using the converter {{CollectionConverter.toSet(java.util.Map<K,V>)}}. Using camel 2.24.1 it produces only one message containing the whole list. This is due to {{ObjectConverterOptimised}} calling {{ObjectHelper.createIterable(java.lang.Object)}} which has a fallback to {{Collections.singletonList(value)}} thus producing a single entry with the whole Map.
The fix is probably to add a {{if (value instanceof Map) { return ((Map)value).entrySet(); } }} but I would like to know what you think about it before doing a pull request.
Thanks
was:
When converting a {{Map}} to an {{Iterable}} the results is no longer the same since CAMEL-11379.
Given the following context
{code}
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer:single?repeatCount=1"/>
<setBody>
<groovy>[A: 'aa', B: 'bb', C: 'cc', D: 'dd']</groovy>
</setBody>
<convertBodyTo type="java.lang.Iterable"/>
<split>
<simple>${body}</simple>
<log message="${body}"/>
</split>
</route>
</routes>
{code}
It produces 4 log messages in camel 2.18.3 using the converter {{CollectionConverter.toSet(java.util.Map<K,V>)}}. Using camel 2.24.1 it produces only one message containing the whole list. This is due to {{ObjectConverterOptimised}} calling {{ObjectHelper.createIterable(java.lang.Object)}} which has a fallback to {{Collections.singletonList(value)}} thus producing a single entry with the whole
> Map to Iterable converter regression
> ------------------------------------
>
> Key: CAMEL-13741
> URL: https://issues.apache.org/jira/browse/CAMEL-13741
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.20.0
> Reporter: Antoine DESSAIGNE
> Priority: Major
>
> When converting a {{Map}} to an {{Iterable}} the results is no longer the same since CAMEL-11379.
> Given the following context
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <routes xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="timer:single?repeatCount=1"/>
> <setBody>
> <groovy>[A: 'aa', B: 'bb', C: 'cc', D: 'dd']</groovy>
> </setBody>
> <convertBodyTo type="java.lang.Iterable"/>
> <split>
> <simple>${body}</simple>
> <log message="${body}"/>
> </split>
> </route>
> </routes>
> {code}
> It produces 4 log messages in camel 2.18.3 using the converter {{CollectionConverter.toSet(java.util.Map<K,V>)}}. Using camel 2.24.1 it produces only one message containing the whole list. This is due to {{ObjectConverterOptimised}} calling {{ObjectHelper.createIterable(java.lang.Object)}} which has a fallback to {{Collections.singletonList(value)}} thus producing a single entry with the whole Map.
> The fix is probably to add a {{if (value instanceof Map) { return ((Map)value).entrySet(); } }} but I would like to know what you think about it before doing a pull request.
> Thanks
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)