Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 062BD173D6 for ; Sat, 1 Aug 2015 16:58:05 +0000 (UTC) Received: (qmail 71201 invoked by uid 500); 1 Aug 2015 16:58:04 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 71159 invoked by uid 500); 1 Aug 2015 16:58:04 -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 71149 invoked by uid 99); 1 Aug 2015 16:58:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Aug 2015 16:58:04 +0000 Date: Sat, 1 Aug 2015 16:58:04 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-5958) Bindy ignores bean class type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-5958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14650455#comment-14650455 ] ASF GitHub Bot commented on CAMEL-5958: --------------------------------------- Github user ke4qqq closed the pull request at: https://github.com/apache/camel/pull/271 > Bindy ignores bean class type > ----------------------------- > > Key: CAMEL-5958 > URL: https://issues.apache.org/jira/browse/CAMEL-5958 > Project: Camel > Issue Type: Bug > Components: camel-bindy > Affects Versions: 2.10.3 > Reporter: Luca Burgazzoli > Priority: Minor > Fix For: 3.0.0 > > > It looks like camel-bindy does not take into account the class specified in the method: > bindy(BindyType.Csv, MyCamelBeans.TEST.class) > I have class MyCamelBeans which includes several "bindies" among which I have a really simple MyCamelBeans.TEST: > class MyCamelBeans { > @CsvRecord(separator=";",isOrdered=true) > public static final class TEST { > @DataField(trim=true,pos= 1) public String tradingDate; > @DataField(trim=true,pos= 2) public String isinCode; > } > ... some other @CsvRecord .... > } > I also have some @FixedLengthRecord classes defined in the same package. > If I run the following route: > from("file:data/test?noop=true&idempotent=true&fileName=test.csv&delay=60000") > .split(body(String.class).tokenize("\n")).streaming() > .unmarshal().bindy(BindyType.Csv, MyCamelBeans.TEST.class) > .to("log:DS?level=INFO&showHeaders=true"); > Camel (2.10.3) fails with an NPE: > java.lang.NullPointerException > at org.apache.camel.dataformat.bindy.BindyCsvFactory.setDefaultValuesForFields(BindyCsvFactory.java:583) > at org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:230) > if I remove the other bindies, camel-bindy works as expected. > Looking at the code, I've found that in BindyAbstractFactory.java : > /** > * method uses to initialize the model representing the classes who will > * bind the data. This process will scan for classes according to the > * package name provided, check the annotated classes and fields. > * > * @throws Exception > */ > public void initModel() throws Exception { > // Find classes defined as Model > if (packageNames != null) { > initModelClasses(this.packageNames); > } else if (type != null) { > // use the package name from the type as it may refer to types in the same package > String pckName = type.getPackage().getName(); > initModelClasses(pckName); > } else { > throw new IllegalArgumentException("Either packagenames or type should be configured"); > } > } > Looks like bindy scan the package even a class has been specified. > Accordin to Claus, bindy needs to be refactored so it > - requires the class type (no more packages) > - uses the class type as root model > - ... and initializes the model from the root, and follow and > references to other classes (if the root has childs) > This avoids picking up any other models. > And we would know to marshal/unmarshal based on the root. -- This message was sent by Atlassian JIRA (v6.3.4#6332)