RESOLVED - issue BATCH-1417: Error in FlatFileItemReader when RecordSeparatorPolicy.preProcess or readLine returns null

Throw FlatFileParseException if file ends in the middle of a record.
This commit is contained in:
dsyer
2009-09-28 08:45:21 +00:00
parent 35d8924626
commit 244e18a019
2 changed files with 46 additions and 2 deletions

View File

@@ -180,7 +180,11 @@ public class FlatFileItemReader<T> extends AbstractItemCountingItemStreamItemRea
String record = line;
if (line != null) {
while (line != null && !recordSeparatorPolicy.isEndOfRecord(record)) {
record = recordSeparatorPolicy.preProcess(record) + (line = readLine());
line = readLine();
if (line==null) {
throw new FlatFileParseException("Unexpected end of file before record complete", record, lineCount);
}
record = recordSeparatorPolicy.preProcess(record) + line;
}
}
String logicalLine = recordSeparatorPolicy.postProcess(record);