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 593DC200BE7 for ; Tue, 20 Dec 2016 17:02:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 58028160B29; Tue, 20 Dec 2016 16:02:08 +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 9E93E160B12 for ; Tue, 20 Dec 2016 17:02:07 +0100 (CET) Received: (qmail 51591 invoked by uid 500); 20 Dec 2016 16:02:06 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 51570 invoked by uid 99); 20 Dec 2016 16:02:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2016 16:02:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D7E6018C6B8 for ; Tue, 20 Dec 2016 16:02:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.487 X-Spam-Level: *** X-Spam-Status: No, score=3.487 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id yypkjsjEe8Jh for ; Tue, 20 Dec 2016 16:02:04 +0000 (UTC) Received: from mbob.nabble.com (mbob.nabble.com [162.253.133.15]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id D3A3B60DA2 for ; Tue, 20 Dec 2016 16:02:03 +0000 (UTC) Received: from static.162.255.23.22.macminivault.com (unknown [162.255.23.22]) by mbob.nabble.com (Postfix) with ESMTP id 7E1863890E23 for ; Tue, 20 Dec 2016 07:47:32 -0800 (PST) Date: Tue, 20 Dec 2016 09:01:33 -0700 (MST) From: dabby11 To: users@camel.apache.org Message-ID: <1482249693354-5791746.post@n5.nabble.com> Subject: camel-bindy issue with header and missing locale MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Tue, 20 Dec 2016 16:02:08 -0000 Hi, I'm developing a route with Camel 2.16.1 that uses Bindy to process a file with fixed length records. The file consists of a header and many rows. I'm unmarshalling the stream with the following data format: BindyFixedLengthDataFormat bindy = new BindyFixedLengthDataFormat(DocumentRow.class); bindy.setLocale("default"); and my model classes are something like: @FixedLengthRecord(header = DocumentHeader.class) public class DocumentRow { ... @DataField(pos = 10, pattern="+000000000.00;-000000000.00", precision = 2, length = 13, decimalSeparator = ",") private BigDecimal value; ... } @FixedLengthRecord public class DocumentHeader { ... @DataField(pos = 365, pattern="+000000000000.00;-000000000000.00", precision = 2, length = 16, decimalSeparator = ",") private BigDecimal total; ... } Bindy fails to parse the DocumentHeader.total field with a java.lang.NumberFormatException. It seems the locale specified with bindy.setLocale("default") is not passed to the inner headerFactory in the BindyFixedLengthDataFormat and Bindy tries to parse the number calling BigDecimal constructor, instead of parsing it with DecimalFormat. Indeed, if I execute the following (ugly!) code before creating the route: bindy.getFactory(); Field field = BindyFixedLengthDataFormat.class.getDeclaredField("headerFactory"); field.setAccessible(true); BindyFixedLengthFactory headerFactory = (BindyFixedLengthFactory)field.get(bindy); headerFactory.setLocale(bindy.getLocale()); to force the locale, everything's fine. So I think that in BindyFixedLengthDataFormat.createModelFactory() after headerFactory creation there should be a call to headerFactory.setLocale(getLocale()) or something like that (and a similar line for footerFactory). I checked 2.17.x and 2.18.x branches of BindyFixedLengthDataFormat.java and there's not something like this. So the question is: is this really an issue with Bindy or should I achieve this result in a different way ? Regards, Marco -- View this message in context: http://camel.465427.n5.nabble.com/camel-bindy-issue-with-header-and-missing-locale-tp5791746.html Sent from the Camel - Users mailing list archive at Nabble.com.