Details
-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
None
Description
Provisioner and loader errors keep coming up because code is calling iterator().next() to get the first element of a collection, without checking for a null collection.
Calling list.iterator().next() is risky because if the list is null, it crashes out with NoSuchElementException rather than returning null. Why not create a GrouperUtil method to get the first element of a list, and return null if the list is null? That's probably the behavior most callers would want.
Additionally, more usage of @Nonnull and @Nullable annotations, and java.util.Optional to make objects more protected against NPEs are good practices, and are used extensively in other projects.