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)