Skip to content

GH-5486: Fix NPE in JpaCursorItemReader.doClose() when reader was nev… - #5489

Open
dhritimanchakra wants to merge 1 commit into
spring-projects:mainfrom
dhritimanchakra:GH-5486
Open

GH-5486: Fix NPE in JpaCursorItemReader.doClose() when reader was nev…#5489
dhritimanchakra wants to merge 1 commit into
spring-projects:mainfrom
dhritimanchakra:GH-5486

Conversation

@dhritimanchakra

Copy link
Copy Markdown

…er opened
entityManager is only assigned in doOpen() and is @Nullable, but
doClose() called entityManager.close() with no null check. Spring
calls close() on every singleton ItemReader bean at context
shutdown regardless of whether its step ran, causing an NPE wrapped
as ItemStreamException for readers that were never opened.

The check was accidentally dropped in 551e26d when @Nullable was
added without preserving the runtime guard.

Fixes #5486

Thank you for taking time to contribute this pull request!
You might have already read the [contributor guide][1], but as a reminder, please make sure to:

  • Rebase your changes on the latest main branch and squash your commits
  • Add/Update unit tests as needed
  • Run a build and make sure all tests pass prior to submission
  • Sign-off commits according to the Developer Certificate of Origin

For more details, please check the [contributor guide][1].
Thank you upfront!

… reader was never opened

entityManager is only assigned in doOpen() and is @nullable, but
doClose() called entityManager.close() with no null check. Spring
calls close() on every singleton ItemReader bean at context
shutdown regardless of whether its step ran, causing an NPE
wrapped as ItemStreamException for readers that were never opened.

The check was accidentally dropped in 551e26d when @nullable was
added without preserving the runtime guard.

Fixes spring-projects#5486

Signed-off-by: Dhritiman Chakrabarty <dhritimancg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JpaCursorItemReader.doClose() missing null check on entityManager

1 participant