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

Generated equals fails on annotated array type #2165

Closed
inreka opened this issue Jun 28, 2019 · 0 comments
Closed

Generated equals fails on annotated array type #2165

inreka opened this issue Jun 28, 2019 · 0 comments

Comments

@inreka
Copy link

inreka commented Jun 28, 2019

Lombok doesn't use array equality for array types with annotations, when generating the equals method.
The following defines a non null array.

@Value
public class TestClass {
    Integer @NonNull [] array;
}

The following test fails.

public class TestClassTest {
    @Test public void equals1() {
        TestClass a = new TestClass(new Integer[]{null});
        TestClass b = new TestClass(new Integer[]{null});
        Assert.assertTrue(Arrays.equals(a.getArray(), b.getArray())); // Succeeds
        Assert.assertEquals(a, b); // Fails
    }
}

If I remove the annotation, the test succeeds.
Alternatively, if I declare the variable as @NonNull Integer [] I get the behavior I was expecting with the above notation, which is a non null array, instead of an array of non null integers.

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

No branches or pull requests

1 participant