jehugaleahsa / FlatFiles

Reads and writes CSV, fixed-length and other flat file formats with a focus on schema definition, configuration and speed.
The Unlicense
357 stars 64 forks source link

Skipping the last fixed length record partition in a file will cause a NullReferenceException #30

Closed TheEvilPenguin closed 6 years ago

TheEvilPenguin commented 6 years ago

If I use IFixedLengthTypeReader.RecordPartitioned to skip the final record in a fixed length file, a NullReferenceException will be thrown in FixedLengthReader.parsePartitions():

at FlatFiles.FixedLengthReader.partitionRecord(FixedLengthSchema schema, String record)   at FlatFiles.FixedLengthReader.partitionWithFilter()   at FlatFiles.FixedLengthReader.parsePartitions()   at FlatFiles.FixedLengthReader.Read()   at FlatFiles.TypeMapping.TypedReader`1.Read()   at...

jehugaleahsa commented 6 years ago

Thanks for the fix and the PR. I added some addition unit tests to reproduce the issue. I decided to consolidate the code that checks for nulls so it's not repeated everywhere. The fix is included in Release 2.1.2.