Uploaded image for project: 'Ranger'
  1. Ranger
  2. RANGER-784

Annotate REST API classes to use get/set methods instead of directly accessing fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.6.0
    • 0.6.0
    • admin
    • None

    Description

      Classes used in REST API are currently annotated such that the JSON serialization/deserialization directly access object fields to read/write. This can cause a field to be set to null while deserializing if the incoming JSON does not include the field or if the value is explicitly set to null.

      Set methods for collection-type fields in many REST API classes (like RangerPolicy/RangerService/RangerServiceDef) sets the field to an empty collection object, when null value is given. This relieves all the code that use these objects from having to check for null.

      Hence it is important for the deserialization to use set method, instead of directly setting the fields. This can be done by replacing the annotation as given below:

      Replace the following:
      @JsonAutoDetect(getterVisibility=Visibility.NONE, setterVisibility=Visibility.NONE, fieldVisibility=Visibility.ANY)

      With:
      @JsonAutoDetect(fieldVisibility=Visibility.ANY)

      Attachments

        Activity

          People

            madhan Madhan Neethiraj
            madhan Madhan Neethiraj
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: