Skip to content

[JAVA] equals and hashCode for models with byte[] vars#6760

Closed
bmordue wants to merge 4 commits intoswagger-api:masterfrom
bmordue:array-equals-issue-3731
Closed

[JAVA] equals and hashCode for models with byte[] vars#6760
bmordue wants to merge 4 commits intoswagger-api:masterfrom
bmordue:array-equals-issue-3731

Conversation

@bmordue
Copy link
Copy Markdown
Contributor

@bmordue bmordue commented Oct 19, 2017

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming langauge.

Description of the PR

For models with a byte array field, the generated equals and hashCode methods are not correct. This change modifies the template to use Array.equals and Arrays.hash for byte array variables.

I think this goes at least some way to being a fix #3731

cc @bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet

jonschoning and others added 4 commits October 19, 2017 09:16
the yaml currently includes invalid definitions that do not exist: ('#/definitions/xmlObject').
revert to known good yaml state.
@bmordue
Copy link
Copy Markdown
Contributor Author

bmordue commented Oct 19, 2017

I based my branch off #6758 to avoid a bunch of unwanted changes in the sample clients.

@bmordue bmordue changed the title Array equals issue 3731 [JAVA] equals and hashCode for models with byte[] vars Oct 19, 2017
@bmordue
Copy link
Copy Markdown
Contributor Author

bmordue commented Oct 19, 2017

I don't know how to cover the three cases of isBinary, isByteArray and "is neither binary nor byte array" with a mustache template. Any tips for that?
Does it need a new variable property (maybe isArray)?

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Nov 8, 2017

Does it need a new variable property (maybe isArray)?

@bmordue Would isListContainer meet your requirement?

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Nov 8, 2017

I'll cherry-pick 533816c later as this PR contains too many changes not relevant to the fix.

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Nov 8, 2017

I don't know how to cover the three cases of isBinary, isByteArray and "is neither binary nor byte array" with a mustache template. Any tips for that?

{{^isBinary}}{{^isByteArray}} ..... {{/isByteArray}}{{/isBinary}} to cover the 3rd case.

@bmordue
Copy link
Copy Markdown
Contributor Author

bmordue commented Jan 8, 2018

I'm closing this PR: #7341 is the same work in a cleaner PR.

@bmordue bmordue closed this Jan 8, 2018
@bmordue bmordue deleted the array-equals-issue-3731 branch January 8, 2018 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JAVA] array equals() fails findbugs

3 participants