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

equals is wrong for byte[] #5

Closed
afdia opened this issue Apr 13, 2016 · 1 comment
Closed

equals is wrong for byte[] #5

afdia opened this issue Apr 13, 2016 · 1 comment

Comments

@afdia
Copy link

afdia commented Apr 13, 2016

First of all thanks for the great plugin! Although there is the jaxb2-basics alternative, I prefer this one, because it doesn't require any additional runtime dependency (I use Guava most of the time therefore it's not really a new one for me) and the generated code is more readable.

Unfortunately there is a bug which causes me to switch back to the "jaxb2-basics" plugin which behaves correctly.

I have the following xsd field:
<element name="pdf" type="base64Binary"/>
which generates
protected byte[] pdf;
in the Java class

You are then using Objects.equal(this.pdf, o.pdf) for the comparison which results in false even if the arrays are equal.
I guess the proper way would be to compare arrays with Arrays.equals(this.pdf, o.pdf) instead, which returns the correct result.

@danielwegener
Copy link
Owner

Hi @afdia, glad you like it! I agree - arrays should be compared by their entries. I can't find my example setup to test it but, guided by the types, #6 should do it. Could you maybe give it a short review?

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

2 participants