You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Angela Schreiber (Jira)" <ji...@apache.org> on 2020/12/03 11:12:00 UTC
[jira] [Created] (SLING-9973) DefaultAclManager.addAclStatement:
redundant check for null
Angela Schreiber created SLING-9973:
---------------------------------------
Summary: DefaultAclManager.addAclStatement: redundant check for null
Key: SLING-9973
URL: https://issues.apache.org/jira/browse/SLING-9973
Project: Sling
Issue Type: Improvement
Components: Content-Package to Feature Model Converter
Reporter: Angela Schreiber
method on https://github.com/apache/sling-org-apache-sling-feature-cpconverter/blob/master/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java#L242 starts as follows:
{code}
private static void addAclStatement(Formatter formatter, String systemUser, List<AccessControlEntry> authorizations) {
if (authorizations == null || areEmpty(authorizations)) {
return;
}
[...]
{code}
utility method {{areEmpty}}:
{code}
private static boolean areEmpty(List<AccessControlEntry> authorizations) {
return authorizations == null || authorizations.isEmpty();
}
{code}
the extra check for null in {{addAclStatement}} can therefore be omitted.... but i suspect one got tricked by the method name.... IMHO it would be better to rename the utility method to {{isNullOrEmpty}} or {{areNullOrEmpty}} (if one considers a list being a plural object).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)