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

[BUG] [Java] Genrated equals doesn't honor nested primitive-array #3182

Closed
yue9944882 opened this issue Jun 20, 2019 · 4 comments · Fixed by #4475
Closed

[BUG] [Java] Genrated equals doesn't honor nested primitive-array #3182

yue9944882 opened this issue Jun 20, 2019 · 4 comments · Fixed by #4475

Comments

@yue9944882
Copy link
Member

xref: kubernetes-client/java#431

the generated equals call for Map<String, byte[]> is broken b/c we didn't apply deep-equal check for nested value entries in the map. the makes equals call permanently returning false..

@wing328
Copy link
Member

wing328 commented Jun 20, 2019

Have you tried the following option?

	useReflectionEqualsHashCode
	    Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact. (Default: false)

@yue9944882
Copy link
Member Author

thanks @wing328, i tried the following snippet and it's working!

        Map<String, byte[]> m1 = new HashMap<String, byte[]>();
        m1.put("foo", new byte[]{0, 1});;;;

        Map<String, byte[]> m2 = new HashMap<String, byte[]>();
        m2.put("foo", new byte[]{0, 1});;;;

        System.out.println(EqualsBuilder.reflectionEquals(m1, m2));
        // true

@yue9944882
Copy link
Member Author

/reopen

@yue9944882
Copy link
Member Author

@wing328 ah oversight.. it doesnt actually solve the issue. we will have to enable the testRecursive option to make that work..

        Map<String, byte[]> data1 = new HashMap<>();
        data1.put("foo", new byte[]{1});
        Map<String, byte[]> data2 = new HashMap<>();
        data2.put("foo", new byte[]{1});
        V1Secret secret1 = new V1Secret().data(data1);
        V1Secret secret2 = new V1Secret().data(data2);
        System.out.println(secret1.equals(secret2)); // false
    }
}

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

Successfully merging a pull request may close this issue.

2 participants