Skip to content
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

Null type safety not working with jakarta.validation.constraints.NotNull #3501

Closed
RMCampos opened this issue Feb 16, 2024 · 4 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#3067
Assignees
Labels

Comments

@RMCampos
Copy link

[provide a description of the issue]

Environment
  • Operating System: Linux Ubuntu 22.04
  • JDK version: 17.0.8 (Oracle GraalVM 17.0.8+9.1 build 17.0.8+9-LTS-jvmci-23.0-b14)
  • Visual Studio Code version: 1.86.2
  • Java extension version: v1.28.1
Steps To Reproduce
  1. Create a method with org.springframework.lang.NonNull annotation
  2. Calls that method with arguments annotated with jakarta.validation.constraints.NotNull
  3. A yellow line shows up on the method call highlighting: Null type safety: The expression of type 'String' needs unchecked conversion to conform to '@NonNull String'Java(16778128)

[Please attach a sample project reproducing the error]
Here:
warnings-bug.zip

Please attach logs
Here:
warning-logs.log

Current Result

VS Code says it could be null, it may have null value.

Expected Result

No warnings at all, since it was annotated with NotNull;

Additional Informations

None

@RMCampos RMCampos changed the title Null type safety not working with jakarta.vaidation.notNull Null type safety not working with jakarta.validation.constraints.NotNull Feb 16, 2024
@snjeza
Copy link
Contributor

snjeza commented Feb 19, 2024

@RMCampos you can try to add

org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore

to <your_project>/.settings/org.eclipse.jdt.core.prefs

@fbricon @rgrunber We could set this property per default when null analysis is enabled.

@RMCampos
Copy link
Author

@snjeza I have to projects inside the same root directory. Shall I put this on the root directory, or inside each project?

@snjeza
Copy link
Contributor

snjeza commented Feb 19, 2024

@RMCampos You may want to take a look at Settings Global Preferences

@RMCampos
Copy link
Author

@snjeza that worked! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants