Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EF5C4200BE0 for ; Fri, 2 Dec 2016 09:01:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EE232160B16; Fri, 2 Dec 2016 08:01:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4ADE6160B29 for ; Fri, 2 Dec 2016 09:01:15 +0100 (CET) Received: (qmail 78581 invoked by uid 500); 2 Dec 2016 08:01:14 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 78448 invoked by uid 99); 2 Dec 2016 08:01:14 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 08:01:14 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 3E1672C0453 for ; Fri, 2 Dec 2016 08:01:14 +0000 (UTC) Date: Fri, 2 Dec 2016 08:01:14 +0000 (UTC) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-10542) DataFormat from registry is used for every dataformat operation (marshal/unmarshal) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 02 Dec 2016 08:01:16 -0000 [ https://issues.apache.org/jira/browse/CAMEL-10542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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} > > > > > > > > > > > > > > > {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)