Skip to content

existsById(…) fails with NullPointerException when metadata does not exist #2991

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

Closed
TheOezzi opened this issue May 31, 2023 · 3 comments
Closed
Labels
type: bug A general bug

Comments

@TheOezzi
Copy link

TheOezzi commented May 31, 2023

Hey all,
After migrating to spring-data-jpa v3.1 I'm currently facing an issue with this check in the existsById Query.

It will not work, as metadata.getComment() will throw a NPE if the metadata is already null.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 31, 2023
@mp911de
Copy link
Member

mp911de commented May 31, 2023

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label May 31, 2023
quaff added a commit to quaff/spring-data-jpa that referenced this issue Jun 2, 2023
1. null check on variable `metadata` is missing in method `existsById`
2. `CrudMethodMetadata::getComment` should be `@Nullable`

Fix spring-projectsGH-2991
@quaff
Copy link
Contributor

quaff commented Jun 2, 2023

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

It's an obvious missing null check, I've created #2995.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 2, 2023
quaff added a commit to quaff/spring-data-jpa that referenced this issue Jun 2, 2023
1. null check on variable `metadata` is missing in method `existsById`
2. `CrudMethodMetadata::getComment` should be `@Nullable`

Fix spring-projectsGH-2991
@TheOezzi
Copy link
Author

TheOezzi commented Jun 2, 2023

Thanks !

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jun 2, 2023
@mp911de mp911de added this to the 3.0.7 (2022.0.7) milestone Jun 2, 2023
@mp911de mp911de changed the title NPE in existsById() in spring-data-jpa-3.1.0 existsById(…) fails with NullPointerException when metadata does not exist Jun 2, 2023
mp911de pushed a commit that referenced this issue Jun 2, 2023
1. null check on variable `metadata` is missing in method `existsById`
2. `CrudMethodMetadata::getComment` should be `@Nullable`

Closes #2991
Original pull request: #2995
mp911de added a commit that referenced this issue Jun 2, 2023
Reuse comment hint retrieval. Reorder methods. Inline methods and use fluent API where possible.

See #2991
Original pull request: #2995
@mp911de mp911de closed this as completed in 03cb819 Jun 2, 2023
mp911de added a commit that referenced this issue Jun 2, 2023
Reuse comment hint retrieval. Reorder methods. Inline methods and use fluent API where possible.

See #2991
Original pull request: #2995
mp911de pushed a commit that referenced this issue Jun 2, 2023
1. null check on variable `metadata` is missing in method `existsById`
2. `CrudMethodMetadata::getComment` should be `@Nullable`

Closes #2991
Original pull request: #2995
mp911de added a commit that referenced this issue Jun 2, 2023
Reuse comment hint retrieval. Reorder methods. Inline methods and use fluent API where possible.

See #2991
Original pull request: #2995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants