MongoItemReader mongoOperation used in doPageRead
to utilize stream
method instead of find
#4502
Labels
doPageRead
to utilize stream
method instead of find
#4502
Bug description
While using
MongoItemReader
, I have configured myStep
bean to utilizefaultTolerant
method and askipLimit
of 5on the skip condition for
IllegalArgumentException
In my current context, there could be data in my database that does not fully conform to the target type provided to the
reader. And I would like to make use of the
faultTolerant
method to skip these dirty data.type provided to MongoItemReader
Repo class
E.g. dirty data from mongodb
However, due to the way
doPageRead
utilizesMongoOperations
to retrieve data as alist
instead of astream
, itis unable to serialize to the type as long as there is dirty data.
So to be able to iterate through the iterator, I have to override the entire
doPageRead
method just to changethe
MongoOperation
method fromfind
tostream
I was wondering if its actually better to utilize
stream
instead asfind
prevents the iterator from iterating if adocument from the database does not conform to the class type provided.
Environment
Expected behavior
If theres non conforming data from the database to the type specified in
MongoItemReader
, it should be able to move onto the next item in the iterator.
Example Repository
https://github.com/ZJTAN97/spring-batch-mongo-item-reader-issue/tree/main
Thank you for reading the issue!
The text was updated successfully, but these errors were encountered: