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
[FEATURE] Ability to suppress run-time null checks of @Getter and @Setter #2078
Comments
Short term work-around: You can create your own annotation, and teach IntelliJ to treat is like a NotNull. Since lombok does not know your annotation, we will not generate a null-check. We are considering a long term solution. The list of built-in non-null annotations is not modifiable from the configuration system. They are hard-coded. Regarding the syntax of the configuration system, the way to make remove individual entries from a list is:
To remove all of them use:
|
I think we now have a solution for you. In If you do so, you will get Assuming that you will not run the application with |
That sounds like a reasonable compromise. Thanks. |
Thanks for the feedback. |
Confirmed working in the edge release. |
The changelog for v1.18.4 contains a surprising change to the behavior of
@Getter
and@Setter
when a nullability annotation is used.Lombok has always had its own
@NonNull
annotation which injected runtime null checking, but you didn't have to use it. If you wanted to use a documentation annotation like JetBrains @NotNull, you could. Lombok would copy it to the getters and setters, but it wouldn't inject any runtime checks.As of 1.18.4, there doesn't appear to be any way of avoiding runtime checks. I generally have IntelliJ IDEA configured to compile runtime null checks for development but omit them from server builds. Lombok's interjection here is redundant with what my IDE is already doing and unwanted on the server.
I tried
lombok.nonNull.flagUsage
values ofwarning
andallow
, but neither kept the runtime check from being added. (I'm not using "NonNull", I'm using JetBrains "NotNull".) The newlombok.copyableAnnotations
property seems to be add-only. I tried= []
and it didn't change anything.In a large code base where nullability annotations are already being used but only for documentation purposes, Lombok's new behavior poses an unwanted risk. It's now possible that a usage pattern that worked (even if it was ill-advised) could start to actively fail. There should be a way to configure the previous behavior.
In other words, I want to configure
public @NotNull @Getter @Setter String foo;
(or the@Data
versions of the same) to produce only the following:The text was updated successfully, but these errors were encountered: