-
Notifications
You must be signed in to change notification settings - Fork 75
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
NullPointerException when using @lombok.NonNull on field #153
Comments
Hi, Thanks for reporting this. Unfortunately, I can't reproduce your issue: for me it works fine. I've created a small GitHub project containing your code: https://github.com/jqno/equalsverifier-issuerepro/tree/issue-153 (Note the branch name). Could you please tweak it so that it produces the NPE you describe? Thanks! |
Hi, I don't have write access to that project so I can't upload my changes. But I have been playing around with it and I believe I have discovered the issue. The error only occurs when the lombok is not available on the runtime classpath (which is the standard way of using lombok since it is only needed at compile time). I don't believe it is possible to reproduce it in a single module project using mvn since
|
Hi, Thanks for the Gradle script, I've been able to reproduce the issue now. I don't have a solution for you yet, but I'll let you know when I do. In the mean time, I suppose the only ways to work around this issue is to have Lombok on your classpath after all, or to use a different NonNull annotation. |
Ok thanks for your help. This issue is not really specific to Lombok, I just happened to discover it while using Lombok. Annotations are just metadata and not usually required to be on the classpath. |
I just released version 2.1.6, which fixes this issue. |
Thanks for the quick fix! |
@jqno it seems the issue is back.
The same problem happens. It's sufficient changing |
Thanks for reporting this. Not sure if it's really the same issue, but I managed to reproduce it. I'll let you know when I have a fix. |
Hm, I thought I'd reproduced the issue yesterday and when I tried again today, it worked fine. @topr can you take a look at https://github.com/jqno/equalsverifier-issuerepro/tree/issue-153-2 (note the branch: I run |
I gave it another try today, still can't reproduce it. I'm going to close this issue again. @topr, if you can reproduce it, feel free to re-open and show me how you did it: please provide a full project with offending test and build script. Take a look at the github project in my previous comment, which should make that easy. |
What steps will reproduce the problem?
Given the following class:
The following test will fail with a NullPointerException:
What error message or stack trace does EqualsVerifier give?
java.lang.AssertionError: NullPointerException
What did you expect?
Test to pass
Which version of EqualsVerifier are you using?
2.1.5
Please provide any additional information below.
Using Project Lombok (https://projectlombok.org/mavenrepo/index.html)
The
@NonNull
annotation will generate a NPE when trying to set the field to anull
value. EqualsVerifier should not be attempting to set fields tonull
when they are marked asNonNull
. In this case since the field is marked asfinal
an NPE will be thrown by the constructor. I can also make everything non-final and use@Data
instead of@Value
on the class. In that case an NPE will be thrown by the setter also. Either way EqualsVerifier does not work.The text was updated successfully, but these errors were encountered: