spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

MongoCursorItemReader throws NullPointerException when closed before opening

Open ryujungkyun opened this issue 1 month ago • 0 comments

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

  1. Create a MongoCursorItemReader instance.
  2. Call close() without calling open() first.
  3. 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().

ryujungkyun avatar Oct 12 '26 14:10 ryujungkyun