pradeepsjsu / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 0 forks source link

NullPointerException on add record error when using spring batch modules #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Create a BeanIOStreamFactory bean
2. Use the factory in a BeanIOFlatFileItemReader and BeanIOFlatFileItemWriter
3. Run a spring batch chunk step using the reader and writer

When a record validation error occurs and the framework try to add the record 
error, a null pointer exception is thrown.

What version of BeanIO are you using? What JDK version?
beanio-1.2.2.jar
jdk-1.6.0_21

See stack trace:
java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:334)
    at java.text.NumberFormat.getInstance(NumberFormat.java:742)
    at java.text.NumberFormat.getInstance(NumberFormat.java:376)
    at java.text.MessageFormat.subformat(MessageFormat.java:1237)
    at java.text.MessageFormat.format(MessageFormat.java:836)
    at java.text.Format.format(Format.java:140)
    at org.beanio.parser.Record.addRecordError(Record.java:194)
    at org.beanio.parser.StreamDefinition$BeanReaderImpl.nextRecord(StreamDefinition.java:572)
    at org.beanio.parser.StreamDefinition$BeanReaderImpl.read(StreamDefinition.java:455)
    at org.beanio.spring.BeanIOFlatFileItemReader.doRead(BeanIOFlatFileItemReader.java:82)
    at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:85)

The issue is caused due to a null Locale variable on BeanIOFlatFileItemReader.
If it's not manually set on the spring bean, no default value is defined.

Try setting the Locale.getDefault();
Method: onOpen()
Line: 121

Original issue reported on code.google.com by mikhas.rock on 12 Jan 2012 at 8:50

GoogleCodeExporter commented 8 years ago
Thank you!  This will be fixed for the next patch release.

Original comment by kevin.s...@gmail.com on 13 Jan 2012 at 2:03

GoogleCodeExporter commented 8 years ago
Fix checked into the trunk.  DefaultStreamFactory modified to use the default 
locale when 'locale' is null.  Diff/patch attached.

Original comment by kevin.s...@gmail.com on 14 Jan 2012 at 5:30

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kevin.s...@gmail.com on 14 Jan 2012 at 5:31