Skip to content

Fix NullPointerException in MongoSequenceIncrementer #4811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blake-bauman
Copy link

When using a MongoDB repository for the first time, the collections used by MongoSequenceIncrementer don't yet exist, which results in the call to findOneAndUpdate().getLong() to reutrn a null, which then results in an NPE unboxing the Long into a long.

Adding upsert(true) creates the initial document with a count of 0 and immediately increments it to 1.

When using a MongoDB repository for the first time, the collections
used by MongoSequenceIncrementer don't yet exist, which results
in the call to findOneAndUpdate().getLong() to reutrn a null,
which then results in an NPE unboxing the Long into a long.

Adding upsert(true) creates the initial document with a
count of 0 and immediately increments it to 1.

Signed-off-by: blake_bauman <[email protected]>
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.

1 participant