camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luca Burgazzoli (JIRA)" <>
Subject [jira] [Created] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal)
Date Mon, 28 Nov 2016 17:08:58 GMT
Luca Burgazzoli created CAMEL-10542:

             Summary: DataFormat from registry is used for every dataformat operation (marshal/unmarshal)
                 Key: CAMEL-10542
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Luca Burgazzoli

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:

<routes xmlns="">
    <from uri="direct:unmarshal"/>
      <csv delimiter=";" headerDisabled="true"/>
    <from uri="direct:marshal"/>
      <csv headerDisabled="true" quoteDisabled="true"/>

And some code like:

InputStream is = getClass().getResourceAsStream("...");

SimpleRegistry reg = new SimpleRegistry();
reg.put("csv-dataformat", new CsvDataFormat());

DefaultCamelContext ctx = new DefaultCamelContext(reg);

ProducerTemplate template = ctx.createProducerTemplate();
String result = template.requestBody(
    Arrays.asList(Arrays.asList( "A1", "B1", "C1" )),

assertEquals("A1,B1,C1", result);


Then this test fails with:

Expected :A1,B1,C1
Actual   :A1;B1;C1

It fails because the object added to the SimpleRegistry is shared among the two csv dataformats
 so it is configured to have delimiter = ';' 

This message was sent by Atlassian JIRA

View raw message