Issue Details (XML | Word | Printable)

Key: BATCH-108
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Lucas Ward
Reporter: Gunnar Hillert
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Spring Batch

Improve error reporting when parsing input files

Created: 22/Aug/07 08:45 PM   Updated: 07/Oct/07 11:45 PM
Component/s: Infrastructure
Affects Version/s: 1.0-m2
Fix Version/s: 1.0-m3
Security Level: Public (Public Issues)

Time Tracking:
Not Specified

Issue Links:
Depends
 


 Description  « Hide
Provide better error reporting when errors occur while parsing an input file.

For example, if a field containing incorrect data could not be parsed, then provide more detailed error information than simply throwing a basic runtime exception (E.g. parsing a date field throws a IllegalArgumentException in org.springframework.batch.io.file.FieldSet).

A common requirement in my projects is often the ability to provide detailed feedback to the users (typically System admin) in case something goes wrong while reading input files. Often it is also desirable to try to read the whole file and provide a collection of occurred errors.

Is there maybe a way to hook into the validator? Also, it would be great if reported errors could contain the row number and field number.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Dave Syer added a comment - 23/Aug/07 01:42 AM
Good ideas (I count at least 3, so might break them out into separate issues at some point) - thanks.

What's wrong with IllegalArgumentException (as long as the error message tells you what happened)? Also a date parsing problem actually gives you quite detailed information about the error (as per the unit tests).

If you want to read the whole file before any processing you can already arrange that as a first step in the job, followed by another step to do some processing. Nothing wrong with that, except if the file is large you might be forced to read it twice (which I can't see any way around even with enhancements).

There is a hook for validation in FlatFileItemProvider, but it is intended to be used for validating objects after they are mapped from a FieldSet, so that's not quite what you wanted?

Lucas Ward added a comment - 07/Oct/07 11:45 PM
As part of fixing BATCH-140, SimpleFlatFileInputSource will now throw a FlatFileParsingException, which contains the original input that caused the error and it's line number. This allows ExceptionHandlers in the ChunkOperations to write out more detailed error logs. Since I feel this meets the basic requirements of this issue, I'm closing it. If more granularity is needed, a new issue should be created.