@NotNull annotations should introduce a null check #344

Closed
lombokissues opened this Issue Jul 14, 2015 · 7 comments

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 271)

@lombokissues
Collaborator

๐Ÿ‘ค anthony@whitford.com ย  ๐Ÿ•— Sep 05, 2011 at 17:28 UTC

Consider the attached code.
It has a @ NotNull annotation on a field member, and the documentation says that delombok will add null checks -- but it does not.

Also note that lombok.NonNull will add the null checks, but the lombok.NonNull annotation is not being removed.

@ java.lang.SuppressWarnings("all")
public void setDataOne(@ NonNull final String dataOne) {
    if (dataOne == null) throw new java.lang.NullPointerException("dataOne");
    this.dataOne = dataOne;
}

@ java.lang.SuppressWarnings("all")
public void setDataTwo(final String dataTwo) {
    this.dataTwo = dataTwo;
}

I am using Java 6 and have witnessed this on Windows and Mac.
I am using Lombok 0.10.0.

@lombokissues
Collaborator

๐Ÿ‘ค anthony@whitford.com ย  ๐Ÿ•— Sep 05, 2011 at 17:28 UTC

๐Ÿ”— NullDataExample.java View file

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Sep 05, 2011 at 17:30 UTC

Issue #343 has been merged into this issue.

@lombokissues
Collaborator

๐Ÿ‘ค anthony@whitford.com ย  ๐Ÿ•— Sep 05, 2011 at 17:32 UTC

BTW... I made a comment about the lombok.NonNull annotation not being removed here:
issue #219
Once 271 is solved, perhaps 146 is solved too.

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Sep 05, 2011 at 17:52 UTC

This issue will only cover the support of @ NotNull.
You can follow the progress of delombok part in ๏นŸ146.

Furthermore we should fix a small inconsistency in the documentation:

"@ Data" states that @ NonNull and @ NotNull will create null checks, while "@ Getter and @ Setter" only states @ NonNull.

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Sep 05, 2011 at 19:59 UTC

fixed with commit:
236c88f

@lombokissues lombokissues removed the accepted label Jul 14, 2015
@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment