This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git


The following commit(s) were added to refs/heads/master by this push:
     new b3be97c0 JEXL: getting ready for 3.3; - last commit;
b3be97c0 is described below

commit b3be97c0914f550156352b7f07002d60ae991119
Author: henrib <hen...@apache.org>
AuthorDate: Thu Mar 9 15:24:50 2023 +0100

    JEXL: getting ready for 3.3;
    - last commit;
---
 .../java/org/apache/commons/jexl3/ClassPermissions.java   | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/ClassPermissions.java 
b/src/test/java/org/apache/commons/jexl3/ClassPermissions.java
index 252d1c9e..0484dfe5 100644
--- a/src/test/java/org/apache/commons/jexl3/ClassPermissions.java
+++ b/src/test/java/org/apache/commons/jexl3/ClassPermissions.java
@@ -21,8 +21,8 @@ import org.apache.commons.jexl3.introspection.JexlPermissions;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -41,9 +41,9 @@ public class ClassPermissions extends 
JexlPermissions.Delegate {
      * @param allow the set of allowed classes
      */
     public ClassPermissions(Class... allow) {
-        this(JexlPermissions.RESTRICTED, allow != null
-                ? 
Arrays.asList(allow).stream().map(Class::getCanonicalName).collect(Collectors.toList())
-                : null);
+        this(JexlPermissions.RESTRICTED,
+            Arrays.asList(Objects.requireNonNull(allow))
+            .stream().map(Class::getCanonicalName) 
.collect(Collectors.toList()));
     }
 
     /**
@@ -53,12 +53,7 @@ public class ClassPermissions extends 
JexlPermissions.Delegate {
      */
     public ClassPermissions(JexlPermissions delegate, Collection<String> 
allow) {
         super(delegate);
-        if (allow != null && !allow.isEmpty()) {
-            allowedClasses = new HashSet<>();
-            allow.forEach(c -> allowedClasses.add(c));
-        } else {
-            allowedClasses = Collections.emptySet();
-        }
+        allowedClasses = new HashSet<>(Objects.requireNonNull(allow));
     }
 
     private boolean isClassAllowed(Class<?> clazz) {

Reply via email to