-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
refactor (kubernetes-model-core) : Refactor IntOrString class to avoid invalid field combinations #3806
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oscerd
approved these changes
Feb 7, 2022
manusa
reviewed
Feb 7, 2022
...nerator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/api/model/IntOrString.java
Outdated
Show resolved
Hide resolved
rohanKanojia
force-pushed
the
pr/intorstring-refactor
branch
5 times, most recently
from
February 8, 2022 13:13
a240a72
to
4507c7b
Compare
rohanKanojia
force-pushed
the
pr/intorstring-refactor
branch
2 times, most recently
from
February 9, 2022 11:04
e97ead3
to
94f78e7
Compare
manusa
reviewed
Feb 9, 2022
StrVal = strVal; | ||
this.additionalProperties = additionalProperties; | ||
} | ||
private transient Object value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this transient? If serialized using Java Serialization it will be ignored (which renders the class useless).
…d invalid field combinations Right now IntOrString determines whether the wapper object contains an integer or string by the value of integer field `kind` - `0` for integer and `1` for string. This field is exposed via setters so it's also possible that user can mutate object to produce invalid combinations. For example: ``` IntOrString i1 = new IntOrString("23"); i1.setIntVal(32); // Would print "23" System.out.println(Serialization.jsonMapper().writeValueAsString(i1)); ``` Refactor IntOrString class to remove these `intVal`,`strVal`,`kind` fields and just rely on one `Object` field; use `instanceOf` to distinguish whether enclosing object is integer or string. We faced an issue due to this behavior in eclipse-jkube/jkube#1126 Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia
force-pushed
the
pr/intorstring-refactor
branch
from
February 9, 2022 13:11
94f78e7
to
0cf0016
Compare
rohanKanojia
changed the title
refactor (kubernetes-model-core) : Remove field setters from IntOrString to avoid invalid field combinations
refactor (kubernetes-model-core) : Refactor IntOrString class to avoid invalid field combinations
Feb 9, 2022
Kudos, SonarCloud Quality Gate passed! |
manusa
approved these changes
Feb 9, 2022
11 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Right now IntOrString determines whether the wapper object contains an
integer or string by the value of integer field
kind
-0
for integerand
1
for string.This field is exposed via setters so it's also possible that user can
mutate object to produce invalid combinations. For example:
Refactor IntOrString class to remove these
intVal
,strVal
,kind
fields and just rely on one
Object
field; useinstanceOf
todistinguish whether enclosing object is integer or string.
We faced an issue due to this behavior in
eclipse-jkube/jkube#1126
Signed-off-by: Rohan Kumar rohaan@redhat.com
Type of change
test, version modification, documentation, etc.)
Checklist