spring-batch
spring-batch copied to clipboard
MongoCursorItemReader throws NullPointerException when closed before opening
Bug description
MongoCursorItemReader throws an ItemStreamException caused by a
NullPointerException when close() is called before open().
The cursor is initialized in doOpen(), but doClose() attempts to
close it without checking whether it has been initialized.
Steps to reproduce
- Create a
MongoCursorItemReaderinstance. - Call
close()without callingopen()first. - Observe the exception.
Expected behavior
Calling close() on an unopened reader should not throw an exception,
as there is no initialized cursor to close.
Actual behavior
An ItemStreamException is thrown, caused by a NullPointerException
because this.cursor is null.
Additional context
JpaCursorItemReader and JpaPagingItemReader already handle
uninitialized resources during doClose().