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

refactor (kubernetes-model-core) : Refactor IntOrString class to avoid invalid field combinations #3806

Merged
merged 1 commit into from
Feb 9, 2022

Commits on Feb 9, 2022

  1. refactor (kubernetes-model-core) : Refactor IntOrString class to avoi…

    …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 committed Feb 9, 2022
    Configuration menu
    Copy the full SHA
    0cf0016 View commit details
    Browse the repository at this point in the history