pingidentity / scim2

The UnboundID SCIM 2.0 SDK for Java
176 stars 72 forks source link

@Attribute annotation silently gets ignored if the field name doesn't match a getter #171

Open doublep opened 1 year ago

doublep commented 1 year ago

Is your feature request related to a problem? Please describe. If you use any non-standard names for storage fields (e.g. _foo rather than just foo), @Attribute annotation on it silently gets ignored. However, since it's the getter that determines what gets delivered as resource properties, this is extremely difficult to notice. In other words, when you access /scim/MyTypeX/123, you get "foo": ... in the response as expected. But the attribute is not present in the response to /scim/Schemas/SCHEMA-URI-FOR-TYPE-X. Renaming field _foo to foo does fix this, but it is extremely unobvious.

Describe the solution you'd like When the library scans for @Attribute, it should complain about annotations on fields with names it doesn't understand (i.e. that don't match property names). If not with exceptions (this would break backward compatibility, though maybe in this case it's worth it), then at least by logging a big fat warning that is easy to spot.

Describe alternatives you've considered As I said, renaming does fix this, but 1) it is unobvious that renaming would be the fix; 2) it is difficult even to spot that something needs to be fixed.