Issue Details (XML | Word | Printable)

Key: BATCH-587
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Robert Kasanicky
Reporter: adrian
Votes: 0
Watchers: 0
Operations

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

more informative exception messages in SpringValidator

Created: 15/Apr/08 02:33 AM   Updated: 07/Aug/08 10:07 AM
Component/s: Infrastructure
Affects Version/s: 1.0.0
Fix Version/s: 1.0.1

Time Tracking:
Not Specified


 Description  « Hide
It would be interesting for logging purposes to have the error item in org.springframework.batch.item.validator.ValidationException (just like FlatFileParseException
 contains the error line and line number).

Something like err.getRejectedValue() or err.getObjectInError() would do it.

Some links : http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/validation/ObjectError.html or http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/validation/FieldError.html (if we want to put informations about the fields themselves that failed validation.

See also forum : http://forum.springframework.org/showpost.php?p=174771&postcount=13

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Robert Kasanicky added a comment - 15/Apr/08 06:45 AM
I think for 1.0.1 we can improve the message string created in the SpringValidator adapter class to be more informative (by including item.toString). If the sole purpose for having access to the item in exception is logging this should help a lot.

I'm not sure including the item itself and/or the validation result object (BeanPropertyBindingResult in spring validator case) would be useful - both item and validation result can be arbitrary objects, so you would need to use instanceof checks or reflection to get more than "toString" information.

Robert Kasanicky added a comment - 15/Apr/08 08:37 AM
Enriched exception messages in SpringValidator - item and validation errors are included in the string.

@adrian: does this solve your logging usecase?

adrian added a comment - 15/Apr/08 02:22 PM
<quote>Does this solve your logging usecase</quote>
-> It 's perfect for me for the 1.0.1. I'll test it tomorrow.
Thanks very much Robert !

I need also to get the detailed item - I'm writing a record in a db table for every skipped item (but franckly I don't know if the item_detail column will be used).
So for this latter usage, I'll wait for my customers real needs - and if they need it I'll wait for Spring Batch 1.1 facilities (as Lucas told in this post :http://forum.springframework.org/showpost.php?p=174758&postcount=11).

Thanks once more for the reactivity !!!

Robert Kasanicky added a comment - 16/Apr/08 02:46 AM
edited the issue summary to reflect what has been done to fix it - we can start a new issue for including the item itself in the exception if desired.

adrian added a comment - 16/Apr/08 02:25 PM
Tested it, works fine.

Thanks !

Sample log output :
Validation failed for com.xxx.yyy.batch.modele.domain.Client@6ba06ba[ChargeClientele=7,numRib=6592236261555,dateAdhesion=Thu Jul 05 00:00:00 CEST 2007,isCorrect=true,contrats=[],identifiant=203494,adresse=com.xxx.yyy.batch.modele.domain.Adresse@6ae06ae[rue=55, Rue Gustave Eiffel,ville=Paris,codePostal=75000,pays=5,paysNaissance=3,villeNaissance=Paris,codePostalNaissance=43000],civilite=4,situationFamiliale=1,nomPatrimonial=ROUXP,nomMarital=,prenom=Pierre,prenom2=Pierre,codeSecu=208642935108231,dateNaissance=Mon Aug 28 00:00:00 CET 1363]:
Field error in object 'item' on field 'dateNaissance': rejected value [Mon Aug 28 00:00:00 CET 1363]; codes [Client.dateNaissance[erreur sur date naissance].item.dateNaissance,Client.dateNaissance[erreur sur date naissance].dateNaissance,Client.dateNaissance[erreur sur date naissance].java.util.Date,Client.dateNaissance[erreur sur date naissance]]; arguments []; default message [erreur sur date naissance]

Dave Syer added a comment - 07/Aug/08 10:07 AM
Assume closed as resolved and released