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 1afb887 JEXL : - Checkstyle 8.37 to 8.39; - Checkstyle 132 columns rules; - Other style issues; new 44ddc25 Merge remote-tracking branch 'origin/master' 1afb887 is described below commit 1afb887a4d8105f2eb28a57202a2090d9021535c Author: henrib <hen...@apache.org> AuthorDate: Mon Jan 4 11:38:29 2021 +0100 JEXL : - Checkstyle 8.37 to 8.39; - Checkstyle 132 columns rules; - Other style issues; --- pom.xml | 2 +- .../java/org/apache/commons/jexl3/JexlEngine.java | 14 +++++------ .../commons/jexl3/internal/ArrayBuilder.java | 2 +- .../org/apache/commons/jexl3/internal/Frame.java | 2 +- .../commons/jexl3/internal/LexicalFrame.java | 2 +- .../commons/jexl3/internal/TemplateEngine.java | 25 ++++++++++++------- .../jexl3/internal/TemplateInterpreter.java | 3 ++- .../commons/jexl3/internal/TemplateScript.java | 8 ++++-- .../jexl3/internal/introspection/ClassMap.java | 10 ++++++-- .../internal/introspection/FieldSetExecutor.java | 5 +++- .../internal/introspection/ListSetExecutor.java | 5 +++- .../internal/introspection/MapSetExecutor.java | 5 +++- .../jexl3/internal/introspection/MethodKey.java | 8 ++++-- .../introspection/PropertyGetExecutor.java | 7 ++++-- .../introspection/PropertySetExecutor.java | 19 ++++++++++---- .../commons/jexl3/introspection/JexlSandbox.java | 29 ++++++++++++++-------- .../commons/jexl3/introspection/JexlUberspect.java | 9 +++++-- 17 files changed, 105 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 99bb3b1..a78b3a3 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ <commons.jira.id>JEXL</commons.jira.id> <commons.jira.pid>12310479</commons.jira.pid> <checkstyle.plugin.version>3.1.1</checkstyle.plugin.version> - <checksyle.version>8.37</checksyle.version> + <checksyle.version>8.39</checksyle.version> <!-- override of version defined in CP52 --> <commons.jacoco.version>0.8.6</commons.jacoco.version> diff --git a/src/main/java/org/apache/commons/jexl3/JexlEngine.java b/src/main/java/org/apache/commons/jexl3/JexlEngine.java index 951b89a..9cdb4f2 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlEngine.java +++ b/src/main/java/org/apache/commons/jexl3/JexlEngine.java @@ -60,13 +60,13 @@ public abstract class JexlEngine { public String toString() { return "tryExecute failed"; } - }; + } /** * The thread local context. */ protected static final java.lang.ThreadLocal<JexlContext.ThreadLocal> CONTEXT = - new java.lang.ThreadLocal<JexlContext.ThreadLocal>(); + new java.lang.ThreadLocal<>(); /** * Accesses the current thread local context. @@ -81,7 +81,7 @@ public abstract class JexlEngine { * The thread local engine. */ protected static final java.lang.ThreadLocal<JexlEngine> ENGINE = - new java.lang.ThreadLocal<JexlEngine>(); + new java.lang.ThreadLocal<>(); /** * Accesses the current thread local engine. @@ -132,7 +132,7 @@ public abstract class JexlEngine { * @return true if strict, false otherwise */ Boolean isStrict(); - + /** * Checks whether the arithmetic triggers errors during evaluation when null is used as an operand. * @@ -161,7 +161,7 @@ public abstract class JexlEngine { */ int getArithmeticMathScale(); } - + /** Default features. */ public static final JexlFeatures DEFAULT_FEATURES = new JexlFeatures(); @@ -193,7 +193,7 @@ public abstract class JexlEngine { public void set(final String name, final Object value) { throw new UnsupportedOperationException("Not supported in void context."); } - }; + } /** * An empty/static/non-mutable JexlNamespace singleton used instead of null namespace. @@ -213,7 +213,7 @@ public abstract class JexlEngine { public Object resolveNamespace(final String name) { return null; } - }; + } /** The default Jxlt cache size. */ private static final int JXLT_CACHE_SIZE = 256; diff --git a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java index 5ad472c..a7789b7 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java +++ b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java @@ -132,7 +132,7 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder { } return typed; } else { - return untyped; + return untyped.clone(); } } else { return new Object[0]; diff --git a/src/main/java/org/apache/commons/jexl3/internal/Frame.java b/src/main/java/org/apache/commons/jexl3/internal/Frame.java index 3dfbe4d..6fc58d9 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Frame.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Frame.java @@ -36,7 +36,7 @@ public final class Frame { * @param r the stack frame * @param c the number of curried parameters */ - public Frame(final Scope s, final Object[] r, final int c) { + Frame(final Scope s, final Object[] r, final int c) { scope = s; stack = r; curried = c; diff --git a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java index 077517b..6bf8cbd 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java +++ b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java @@ -31,7 +31,7 @@ public class LexicalFrame extends LexicalScope { /** * Previous frame. */ - protected LexicalFrame previous; + protected final LexicalFrame previous; /** * The stack of values in the lexical frame. */ diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java index 33a49db..855ad78 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java @@ -60,7 +60,11 @@ public final class TemplateEngine extends JxltEngine { * @param immediate the immediate template expression character, default is '$' * @param deferred the deferred template expression character, default is '#' */ - public TemplateEngine(final Engine aJexl, final boolean noScript, final int cacheSize, final char immediate, final char deferred) { + public TemplateEngine(final Engine aJexl, + final boolean noScript, + final int cacheSize, + final char immediate, + final char deferred) { this.jexl = aJexl; this.cache = new SoftCache<>(cacheSize); immediateChar = immediate; @@ -327,7 +331,7 @@ public final class TemplateEngine extends JxltEngine { protected JexlOptions options(final JexlContext context) { return jexl.options(null, context); } - + /** * Evaluates this expression. * @param frame the frame storing parameters and local variables @@ -436,7 +440,7 @@ public final class TemplateEngine extends JxltEngine { strb.append("}"); return strb; } - + @Override protected JexlOptions options(final JexlContext context) { return jexl.options(node instanceof ASTJexlScript? (ASTJexlScript) node : null, context); @@ -705,7 +709,10 @@ public final class TemplateEngine extends JxltEngine { * @param xany the exception * @return an exception containing an explicit error message */ - static Exception createException(final JexlInfo info, final String action, final TemplateExpression expr, final java.lang.Exception xany) { + static Exception createException(final JexlInfo info, + final String action, + final TemplateExpression expr, + final java.lang.Exception xany) { final StringBuilder strb = new StringBuilder("failed to "); strb.append(action); if (expr != null) { @@ -746,13 +753,13 @@ public final class TemplateEngine extends JxltEngine { * @param expr the source * @param position the offset into the source * @param c the separator character - * @return the new position to read the source from + * @return the new position to read the source from */ private static int append(final StringBuilder strb, final CharSequence expr, final int position, final char c) { strb.append(c); if (c != '"' && c != '\'') { return position; - } + } // read thru strings final int end = expr.length(); boolean escape= false; @@ -770,7 +777,7 @@ public final class TemplateEngine extends JxltEngine { } return index; } - + /** * Parses a unified expression. * @param info the source info @@ -989,7 +996,7 @@ public final class TemplateEngine extends JxltEngine { line = theLine; body = theBlock; } - + /** * @return type */ @@ -1199,4 +1206,4 @@ public final class TemplateEngine extends JxltEngine { public TemplateScript createTemplate(final JexlInfo info, final String prefix, final Reader source, final String... parms) { return new TemplateScript(this, info, prefix, source, parms); } -} \ No newline at end of file +} diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java index c3ecc27..61f1c20 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java @@ -19,6 +19,7 @@ package org.apache.commons.jexl3.internal; import org.apache.commons.jexl3.JexlContext; import org.apache.commons.jexl3.JexlInfo; import org.apache.commons.jexl3.JexlOptions; +import org.apache.commons.jexl3.JxltEngine; import org.apache.commons.jexl3.internal.TemplateEngine.TemplateExpression; import org.apache.commons.jexl3.introspection.JexlMethod; import org.apache.commons.jexl3.introspection.JexlUberspect; @@ -130,7 +131,7 @@ public class TemplateInterpreter extends Interpreter { * @param script the TemplateScript to evaluate * @param args the arguments */ - public void include(final TemplateScript script, final Object... args) { + public void include(final JxltEngine.Template script, final Object... args) { script.evaluate(context, writer, args); } diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java index 129bc59..0f0a2a4 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java @@ -65,7 +65,11 @@ public final class TemplateScript implements JxltEngine.Template { * @throws NullPointerException if either the directive prefix or input is null * @throws IllegalArgumentException if the directive prefix is invalid */ - public TemplateScript(final TemplateEngine engine, JexlInfo info, final String directive, final Reader reader, final String... parms) { + public TemplateScript(final TemplateEngine engine, + JexlInfo info, + final String directive, + final Reader reader, + final String... parms) { if (directive == null) { throw new NullPointerException("null prefix"); } @@ -186,7 +190,7 @@ public final class TemplateScript implements JxltEngine.Template { /** * Collects the scope surrounding a call to jexl:print(i). - * <p>This allows to later parse the blocks with the known symbols + * <p>This allows to later parse the blocks with the known symbols * in the frame visible to the parser. * @param node the visited node * @param minfo the map of printed expression number to node info diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java index e0dae57..e54e977 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java @@ -263,7 +263,10 @@ final class ClassMap { * @param iface the interface to populate the cache from * @param log the Log */ - private static void populateWithInterface(final ClassMap cache, final Permissions permissions, final Class<?> iface, final Log log) { + private static void populateWithInterface(final ClassMap cache, + final Permissions permissions, + final Class<?> iface, + final Log log) { if (Modifier.isPublic(iface.getModifiers())) { populateWithClass(cache, permissions, iface, log); final Class<?>[] supers = iface.getInterfaces(); @@ -281,7 +284,10 @@ final class ClassMap { * @param clazz the class to populate the cache from * @param log the Log */ - private static void populateWithClass(final ClassMap cache, final Permissions permissions, final Class<?> clazz, final Log log) { + private static void populateWithClass(final ClassMap cache, + final Permissions permissions, + final Class<?> clazz, + final Log log) { try { final Method[] methods = clazz.getDeclaredMethods(); for (final Method mi : methods) { diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java index 75f6b81..3095a21 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java @@ -39,7 +39,10 @@ public final class FieldSetExecutor implements JexlPropertySet { * @param value the value to set the field to * @return the executor if found, null otherwise */ - public static JexlPropertySet discover(final Introspector is, final Class<?> clazz, final String identifier, final Object value) { + public static JexlPropertySet discover(final Introspector is, + final Class<?> clazz, + final String identifier, + final Object value) { if (identifier != null) { final Field field = is.getField(clazz, identifier); if (field != null diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ListSetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ListSetExecutor.java index 14c2f7d..4c6444b 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ListSetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ListSetExecutor.java @@ -42,7 +42,10 @@ public final class ListSetExecutor extends AbstractExecutor.Set { * @param value the value to use as argument in list.put(key,value) * @return the executor if found, null otherwise */ - public static ListSetExecutor discover(final Introspector is, final Class<?> clazz, final Object identifier, final Object value) { + public static ListSetExecutor discover(final Introspector is, + final Class<?> clazz, + final Object identifier, + final Object value) { final Integer index = castInteger(identifier); if (index != null) { if (clazz.isArray()) { diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/MapSetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/MapSetExecutor.java index 7acbd47..c3eec2a 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/MapSetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/MapSetExecutor.java @@ -39,7 +39,10 @@ public final class MapSetExecutor extends AbstractExecutor.Set { * @param value the value to use as argument in map.put(key,value) * @return the executor if found, null otherwise */ - public static MapSetExecutor discover(final Introspector is, final Class<?> clazz, final Object identifier, final Object value) { + public static MapSetExecutor discover(final Introspector is, + final Class<?> clazz, + final Object identifier, + final Object value) { if (Map.class.isAssignableFrom(clazz)) { return new MapSetExecutor(clazz, MAP_SET, identifier, value); } else { diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java index 3571fc2..fe8aca4 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java @@ -259,7 +259,9 @@ public final class MethodKey { * type or an object type of a primitive type that can be converted to * the formal type. */ - public static boolean isInvocationConvertible(final Class<?> formal, final Class<?> actual, final boolean possibleVarArg) { + public static boolean isInvocationConvertible(final Class<?> formal, + final Class<?> actual, + final boolean possibleVarArg) { return isInvocationConvertible(formal, actual, false, possibleVarArg); } @@ -279,7 +281,9 @@ public final class MethodKey { * or formal and actual are both primitive types and actual can be * subject to widening conversion to formal. */ - public static boolean isStrictInvocationConvertible(final Class<?> formal, final Class<?> actual, final boolean possibleVarArg) { + public static boolean isStrictInvocationConvertible(final Class<?> formal, + final Class<?> actual, + final boolean possibleVarArg) { return isInvocationConvertible(formal, actual, true, possibleVarArg); } diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertyGetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertyGetExecutor.java index a1329ce..925f0b8 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertyGetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertyGetExecutor.java @@ -75,7 +75,7 @@ public final class PropertyGetExecutor extends AbstractExecutor.Get { return TRY_FAILED;// fail } catch (final InvocationTargetException xinvoke) { throw JexlException.tryFailed(xinvoke); // throw - } + } } return TRY_FAILED; } @@ -88,7 +88,10 @@ public final class PropertyGetExecutor extends AbstractExecutor.Get { * @param property The property being addressed. * @return The {get,is}{p,P}roperty method if one exists, null otherwise. */ - static java.lang.reflect.Method discoverGet(final Introspector is, final String which, final Class<?> clazz, final String property) { + static java.lang.reflect.Method discoverGet(final Introspector is, + final String which, + final Class<?> clazz, + final String property) { if (property == null || property.isEmpty()) { return null; } diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertySetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertySetExecutor.java index 6a09383..f883371 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertySetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/PropertySetExecutor.java @@ -42,7 +42,10 @@ public class PropertySetExecutor extends AbstractExecutor.Set { * @param value the value to assign to the property * @return the executor if found, null otherwise */ - public static PropertySetExecutor discover(final Introspector is, final Class<?> clazz, final String property, final Object value) { + public static PropertySetExecutor discover(final Introspector is, + final Class<?> clazz, + final String property, + final Object value) { if (property == null || property.isEmpty()) { return null; } @@ -57,7 +60,10 @@ public class PropertySetExecutor extends AbstractExecutor.Set { * @param key the key to use as 1st argument to the set method * @param value the value */ - protected PropertySetExecutor(final Class<?> clazz, final java.lang.reflect.Method method, final String key, final Object value) { + protected PropertySetExecutor(final Class<?> clazz, + final java.lang.reflect.Method method, + final String key, + final Object value) { super(clazz, method); property = key; valueClass = classOf(value); @@ -81,7 +87,7 @@ public class PropertySetExecutor extends AbstractExecutor.Set { } } method.invoke(o, arg); - } + } return arg; } @@ -100,7 +106,7 @@ public class PropertySetExecutor extends AbstractExecutor.Set { return TRY_FAILED;// fail } catch (final InvocationTargetException xinvoke) { throw JexlException.tryFailed(xinvoke); // throw - } + } } return TRY_FAILED; } @@ -125,7 +131,10 @@ public class PropertySetExecutor extends AbstractExecutor.Set { * @param arg the value to assign to the property * @return the method if found, null otherwise */ - private static java.lang.reflect.Method discoverSet(final Introspector is, final Class<?> clazz, final String property, final Object arg) { + private static java.lang.reflect.Method discoverSet(final Introspector is, + final Class<?> clazz, + final String property, + final Object arg) { // first, we introspect for the set<identifier> setter method final Object[] params = {arg}; final StringBuilder sb = new StringBuilder("set"); diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java index 5b9f6dd..eb05ff5 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java @@ -380,19 +380,19 @@ public final class JexlSandbox { return names != null && !names.contains(name) ? name : null; } } - + /** * Unused. */ @Deprecated public static final class WhiteSet extends AllowSet {} - + /** * Unused. */ @Deprecated public static final class BlackSet extends BlockSet {} - + /** * Contains the allow or block lists for properties and methods for a given class. */ @@ -537,10 +537,13 @@ public final class JexlSandbox { * @param executeFlag whether the executable method list is allow allow - true - or block - false - * @return the set of permissions */ - public Permissions permissions(final String clazz, final boolean readFlag, final boolean writeFlag, final boolean executeFlag) { + public Permissions permissions(final String clazz, + final boolean readFlag, + final boolean writeFlag, + final boolean executeFlag) { return permissions(clazz, inherit, readFlag, writeFlag, executeFlag); } - + /** * Creates the set of permissions for a given class. * @@ -551,7 +554,11 @@ public final class JexlSandbox { * @param execf whether the executable method list is allow allow - true - or block - false - * @return the set of permissions */ - public Permissions permissions(final String clazz, final boolean inhf, final boolean readf, final boolean writef, final boolean execf) { + public Permissions permissions(final String clazz, + final boolean inhf, + final boolean readf, + final boolean writef, + final boolean execf) { final Permissions box = new Permissions(inhf, readf, writef, execf); sandbox.put(clazz, box); return box; @@ -560,14 +567,14 @@ public final class JexlSandbox { /** * Creates a new set of permissions based on allow lists for methods and properties for a given class. * <p>The sandbox inheritance property will apply to the permissions created by this method - * + * * @param clazz the allowed class name * @return the permissions instance */ public Permissions allow(final String clazz) { return permissions(clazz, true, true, true); } - /** + /** * Use allow() instead. * @param clazz the allowed class name * @return the permissions instance @@ -587,8 +594,8 @@ public final class JexlSandbox { public Permissions block(final String clazz) { return permissions(clazz, false, false, false); } - - /** + + /** * Use block() instead. * @param clazz the allowed class name * @return the permissions instance @@ -659,4 +666,4 @@ public final class JexlSandbox { return permissions; } -} \ No newline at end of file +} diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlUberspect.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlUberspect.java index 63d1307..30a484a 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlUberspect.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlUberspect.java @@ -97,12 +97,17 @@ public interface JexlUberspect { CONTAINER; @Override - public final JexlPropertyGet getPropertyGet(final JexlUberspect uber, final Object obj, final Object identifier) { + public final JexlPropertyGet getPropertyGet(final JexlUberspect uber, + final Object obj, + final Object identifier) { return uber.getPropertyGet(Collections.singletonList(this), obj, identifier); } @Override - public final JexlPropertySet getPropertySet(final JexlUberspect uber, final Object obj, final Object identifier, final Object arg) { + public final JexlPropertySet getPropertySet(final JexlUberspect uber, + final Object obj, + final Object identifier, + final Object arg) { return uber.getPropertySet(Collections.singletonList(this), obj, identifier, arg); } }