[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2017-02-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on CAMEL-10542:


Github user asfgit closed the pull request at:

https://github.com/apache/camel/pull/1436


> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.3, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2017-01-05 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

There is more work to do, I'm doing some experiment at the moment

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2017-01-05 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-10542:
-

Luca, did you implement this or is there more work to do here?

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-02 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-10542:
-

Ah okay, yeah give that a try and see how that goes.


> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

I was thinking about a real factory that can create an instance of a 
dataformat, like what you can achieve by annotate a method with prototype scope 
in spring

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-10542:
-

By DataFormatFactory do you mean DataFormatResolver?

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

Maybe a better way would be:

- if a ref is set, look it up and use it as it is
- if ref is not set, search for a DataFormatFactory instead of DataFormat
- if factory is not found go ahead with standard resolution

So that spring-boot or any other container can safely register its factory as 
i.e. csv-factory or csv-dataformat-factory

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

Thinking a little bit more if we do so we may have other issues in spring-boot 
as I may want to do:

{code:java}
from(...)
  .marshal()
.csv()
{code}

And have the csv marshal leveraging spring-boot auto configuration but if we 
require to use a reference, the spring-configuration magic won't happen any 
more, am I missing something ?


> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

Going to have a look, thx [~davsclaus]

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-12-01 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-10542:
-

You could argue that  ... should use its own instance as there is 
no reference to a named data format, where as using  then you are using that shared your add to the registry.

So its maybe more in how  creates the dataformat that needs to be 
looked at / fixed.

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-11-30 Thread Luca Burgazzoli (JIRA)

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

Luca Burgazzoli commented on CAMEL-10542:
-

Yes you don't as in such case the dataformat instance is created using 
"service-loader" style thus a new instance is created each time 
DefaultDataFormatResolver::resolveDataFormat is invoked.

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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


[jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)

2016-11-30 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-10542:
-

So if you change the name from "csv-dataformat" to "foo" then you dont have 
this problem?

> DataFormat from registry is used for every dataformat operation 
> (marshal/unmarshal)
> ---
>
> Key: CAMEL-10542
> URL: https://issues.apache.org/jira/browse/CAMEL-10542
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Reporter: Luca Burgazzoli
>Assignee: Luca Burgazzoli
> Fix For: 2.18.2, 2.19.0
>
>
> While working on an issue related to spring-boot I found out that if a data 
> format is registered in camel registry with the same name as the one camel 
> looks-up with the help of DefaultDataFormatResolver, this object is then 
> re-configured for each data format definition so one definition may override 
> previous configuration with an undefined behavior.
> So assume you have an xml route definitions as:
> {code:xml}
> http://camel.apache.org/schema/spring;>
>   
> 
> 
>   
> 
>   
>   
> 
> 
>   
> 
>   
> 
> {code}
> And some code like:
> {code:java}
> InputStream is = getClass().getResourceAsStream("...");
> SimpleRegistry reg = new SimpleRegistry();
> reg.put("csv-dataformat", new CsvDataFormat());
> DefaultCamelContext ctx = new DefaultCamelContext(reg);
> ctx.addRouteDefinitions(ctx.loadRoutesDefinition(is).getRoutes());
> ctx.start();
> ProducerTemplate template = ctx.createProducerTemplate();
> String result = template.requestBody(
> "direct:marshal",
> Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),
> String.class);
> assertEquals("A1,B1,C1", result);
> ctx.stop
> {code}
> Then this test fails with:
> {code}
> Expected :A1,B1,C1
> Actual   :A1;B1;C1
> {code}
> It fails because the object added to the SimpleRegistry is shared among the 
> two csv dataformats  so it is configured to have delimiter = ';' 
> For spring-boot this causes some issues as it registers data formats beans as 
> part of its auto-configuration magic thus if you do not set your own instance 
> of data format, any data format operation like marshal/unmarshal may not work 
> as expected. 
> - for spring-boot a solution would be to annotate auto configured data format 
> beans with prototype scope.
> - a more generic solution would be to make DataFormat Cloneable and clone the 
> bean found in the registry



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