[jira] [Commented] (CAMEL-19837) Converters - unpredictable behavior linked to type hierarchy (flatpack)

2023-09-06 Thread Jiri Ondrusek (Jira)


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

Jiri Ondrusek commented on CAMEL-19837:
---

This test: 
https://github.com/apache/camel-quarkus/blob/camel-main/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java#L135-L161

> Converters - unpredictable behavior linked to type hierarchy (flatpack)
> ---
>
> Key: CAMEL-19837
> URL: https://issues.apache.org/jira/browse/CAMEL-19837
> Project: Camel
>  Issue Type: Bug
>  Components: core
>Affects Versions: 4.x
>Reporter: Jiri Ondrusek
>Priority: Major
>
> Consequence of 
> [https://github.com/apache/camel/pull/11225/commits/e4007f2b1dfc982e5ea6a45427cbec8835ea58a5]
>  
> Camel-flatpack registers 2 converters: 
>  # from net.sf.flatpack.DataSet to Map
>  # from net.sf.flatpack.Record to Map
> Problematic case: If data for conversion is instance of 
> net.sf.flatpack.DefaultDataSet
>  
> Direct conversion is not possible (there is no DefaultDataSet -> Map 
> converter)
> therefore matching via interface is used (see 
> [https://github.com/apache/camel/blob/main/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java#L101-L110)]
>  
> Problem is that `DefaultDataSet` implements `DataSet`, which extends `Record`.
>  
> Therefore based on the order of converters in the cache (map), "random" 
> converter is selected and used. Unfortunately one of these selection might 
> cause a problem.
>  
> I was trying to run test `fixedHeaderAndTrailerShouldSucceed` in 
> camel-quarkus from branch `camel-main`.  
> [code|https://github.com/apache/camel-quarkus/blob/camel-main/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java#L133]
>  # In case that converter `DataSet` -> `Map` is selected, the test 
> {*}succeeds{*}.
>  # If `Record` -> `Map` is selected, test {*}fails{*}.
>  
> I'd suggest to add a logic, which takes into consideration the fact, that 
> some of the matched interfaces are more general and some are more specific 
> (in this case, `DataSet` conversion should have higher priority).
> There might be other approaches, but ^^ this one makes sense and should be 
> implementable (I'm not sure about possible performance affect)
>  
> (another way might be defining order of the converters, `DataSet` is always 
> tried before `Record` in Flatpack, performance should be better)



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


[jira] [Commented] (CAMEL-19837) Converters - unpredictable behavior linked to type hierarchy (flatpack)

2023-09-05 Thread Otavio Rodolfo Piske (Jira)


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

Otavio Rodolfo Piske commented on CAMEL-19837:
--

[~jondruse] what test is this one? 

> Converters - unpredictable behavior linked to type hierarchy (flatpack)
> ---
>
> Key: CAMEL-19837
> URL: https://issues.apache.org/jira/browse/CAMEL-19837
> Project: Camel
>  Issue Type: Bug
>  Components: core
>Affects Versions: 4.x
>Reporter: Jiri Ondrusek
>Priority: Major
>
> Consequence of 
> [https://github.com/apache/camel/pull/11225/commits/e4007f2b1dfc982e5ea6a45427cbec8835ea58a5]
>  
> Camel-flatpack registers 2 converters: 
>  # from net.sf.flatpack.DataSet to Map
>  # from net.sf.flatpack.Record to Map
> Problematic case: If data for conversion is instance of 
> net.sf.flatpack.DefaultDataSet
>  
> Direct conversion is not possible (there is no DefaultDataSet -> Map 
> converter)
> therefore matching via interface is used (see 
> [https://github.com/apache/camel/blob/main/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java#L101-L110)]
>  
> Problem is that `DefaultDataSet` implements `DataSet`, which extends `Record`.
>  
> Therefore based on the order of converters in the cache (map), "random" 
> converter is selected and used. Unfortunately one of these selection might 
> cause a problem.
>  
> I was trying to run test `fixedHeaderAndTrailerShouldSucceed` in 
> camel-quarkus from branch `camel-main`.  
> [code|https://github.com/apache/camel-quarkus/blob/camel-main/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java#L133]
>  # In case that converter `DataSet` -> `Map` is selected, the test 
> {*}succeeds{*}.
>  # If `Record` -> `Map` is selected, test {*}fails{*}.
>  
> I'd suggest to add a logic, which takes into consideration the fact, that 
> some of the matched interfaces are more general and some are more specific 
> (in this case, `DataSet` conversion should have higher priority).
> There might be other approaches, but ^^ this one makes sense and should be 
> implementable (I'm not sure about possible performance affect)
>  
> (another way might be defining order of the converters, `DataSet` is always 
> tried before `Record` in Flatpack, performance should be better)



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


[jira] [Commented] (CAMEL-19837) Converters - unpredictable behavior linked to type hierarchy (flatpack)

2023-09-05 Thread Jiri Ondrusek (Jira)


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

Jiri Ondrusek commented on CAMEL-19837:
---

FYI  ^ [~orpiske] 

> Converters - unpredictable behavior linked to type hierarchy (flatpack)
> ---
>
> Key: CAMEL-19837
> URL: https://issues.apache.org/jira/browse/CAMEL-19837
> Project: Camel
>  Issue Type: Bug
>  Components: core
>Affects Versions: 4.x
>Reporter: Jiri Ondrusek
>Priority: Major
>
> Consequence of 
> [https://github.com/apache/camel/pull/11225/commits/e4007f2b1dfc982e5ea6a45427cbec8835ea58a5]
>  
> Camel-flatpack registers 2 converters: 
>  # from net.sf.flatpack.DataSet to Map
>  # from net.sf.flatpack.Record to Map
> Problematic case: If data for conversion is instance of 
> net.sf.flatpack.DefaultDataSet
>  
> Direct conversion is not possible (there is no DefaultDataSet -> Map 
> converter)
> therefore matching via interface is used (see 
> [https://github.com/apache/camel/blob/main/core/camel-api/src/main/java/org/apache/camel/converter/TypeConvertible.java#L101-L110)]
>  
> Problem is that `DefaultDataSet` implements `DataSet`, which extends `Record`.
>  
> Therefore based on the order of converters in the cache (map), "random" 
> converter is selected and used. Unfortunately one of these selection might 
> cause a problem.
>  
> I was trying to run test `fixedHeaderAndTrailerShouldSucceed` in 
> camel-quarkus from branch `camel-main`.  
> [code|https://github.com/apache/camel-quarkus/blob/camel-main/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java#L133]
>  # In case that converter `DataSet` -> `Map` is selected, the test 
> {*}succeeds{*}.
>  # If `Record` -> `Map` is selected, test {*}fails{*}.
>  
> I'd suggest to add a logic, which takes into consideration the fact, that 
> some of the matched interfaces are more general and some are more specific 
> (in this case, `DataSet` conversion should have higher priority).
> There might be other approaches, but ^^ this one makes sense and should be 
> implementable (I'm not sure about possible performance affect)
>  
> (another way might be defining order of the converters, `DataSet` is always 
> tried before `Record` in Flatpack, performance should be better)



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