This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit b6c39bac8012b6d4f3adf3adcbba36753a13bebc Author: Mark Thomas <[email protected]> AuthorDate: Mon Mar 29 15:14:26 2021 +0100 No functional change. Align 10.0.x, 9.0.x and 8.5.x. --- java/org/apache/el/ExpressionFactoryImpl.java | 7 ------- java/org/apache/el/Messages.properties | 11 ++++++++++- java/org/apache/el/lang/ExpressionBuilder.java | 5 ++--- java/org/apache/el/lang/FunctionMapperFactory.java | 4 +++- java/org/apache/el/lang/FunctionMapperImpl.java | 5 +++-- java/org/apache/el/lang/VariableMapperFactory.java | 6 ++++-- java/org/apache/el/parser/AstIdentifier.java | 9 ++------- java/org/apache/el/parser/AstLambdaExpression.java | 2 +- java/org/apache/el/parser/AstMethodParameters.java | 3 ++- java/org/apache/el/parser/TokenMgrError.java | 4 ++-- java/org/apache/el/util/ReflectionUtil.java | 7 +------ 11 files changed, 30 insertions(+), 33 deletions(-) diff --git a/java/org/apache/el/ExpressionFactoryImpl.java b/java/org/apache/el/ExpressionFactoryImpl.java index e32eced..4bd8fc3 100644 --- a/java/org/apache/el/ExpressionFactoryImpl.java +++ b/java/org/apache/el/ExpressionFactoryImpl.java @@ -35,13 +35,6 @@ import org.apache.el.util.MessageFactory; */ public class ExpressionFactoryImpl extends ExpressionFactory { - /** - * - */ - public ExpressionFactoryImpl() { - super(); - } - @Override public Object coerceToType(Object obj, Class<?> type) { return ELSupport.coerceToType(null, obj, type); diff --git a/java/org/apache/el/Messages.properties b/java/org/apache/el/Messages.properties index fbce247..1bf600d 100644 --- a/java/org/apache/el/Messages.properties +++ b/java/org/apache/el/Messages.properties @@ -14,9 +14,15 @@ # limitations under the License. # General Errors +error.cannotSetVariables=Cannot set variables on factory error.convert=Cannot convert [{0}] of type [{1}] to [{2}] error.compare=Cannot compare [{0}] to [{1}] error.function=Problems calling function [{0}] +error.invalidMethodExpression=Not a valid method expression [{0}] +error.noFunctionMapperTarget=FunctionMapper target cannot be null +error.noVariableMapperTarget=FunctionMapper target cannot be null +error.nullLocalName=Local name cannot be null +error.nullMethod=Method cannot be null error.unreachable.base=Target Unreachable, identifier [{0}] resolved to null error.unreachable.property=Target Unreachable, [{0}] returned null error.resolver.unhandled=ELResolver did not handle type: [{0}] with property of [{1}] @@ -29,7 +35,7 @@ error.value.literal.write=ValueExpression is a literal and not writable: [{0}] # ExpressionFactoryImpl error.null=Expression cannot be null -error.mixed=Expression cannot contain both '#{...}' and '${...}' : [{0}] +error.mixed=Expression cannot contain both ''#{...}'' and ''${...}'' : [{0}] error.method=Not a valid MethodExpression : [{0}] error.method.nullParms=Parameter types cannot be null error.value.expectedType=Expected type cannot be null @@ -54,8 +60,11 @@ error.context.null=ELContext was null # Parser error.function.tooManyMethodParameterSets=There are multiple sets of parameters specified for function [{0}] +error.identifier.noMethod=Identity [{0}] was null and was unable to invoke error.identifier.notjava=The identifier [{0}] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true. +error.identifier.notMethodExpression=Identity [{0}] does not reference a method expression instance, returned type [{1}] error.lambda.tooManyMethodParameterSets=There are more sets of method parameters specified than there are nested lambda expressions +error.lambda.wrongNestedState=Nested state may only be set once # Stream stream.compare.notComparable=Stream elements must implement Comparable diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index cde34a6..6c3620b 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -230,7 +230,7 @@ public final class ExpressionBuilder implements NodeVisitor { "" + methodParameterCount, "" + node.jjtGetChild(0).jjtGetNumChildren())); } } else if (node instanceof AstIdentifier && this.varMapper != null) { - String variable = ((AstIdentifier) node).getImage(); + String variable = node.getImage(); // simply capture it this.varMapper.resolveVariable(variable); @@ -258,8 +258,7 @@ public final class ExpressionBuilder implements NodeVisitor { return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { - throw new ELException("Not a Valid Method Expression: " - + expression); + throw new ELException(MessageFactory.get("error.invalidMethodExpression", expression)); } } diff --git a/java/org/apache/el/lang/FunctionMapperFactory.java b/java/org/apache/el/lang/FunctionMapperFactory.java index 835f468..59b6cb6 100644 --- a/java/org/apache/el/lang/FunctionMapperFactory.java +++ b/java/org/apache/el/lang/FunctionMapperFactory.java @@ -21,6 +21,8 @@ import java.lang.reflect.Method; import javax.el.FunctionMapper; +import org.apache.el.util.MessageFactory; + /** * @author Jacob Hookom [[email protected]] */ @@ -31,7 +33,7 @@ public class FunctionMapperFactory extends FunctionMapper { public FunctionMapperFactory(FunctionMapper mapper) { if (mapper == null) { - throw new NullPointerException("FunctionMapper target cannot be null"); + throw new NullPointerException(MessageFactory.get("error.noFunctionMapperTarget")); } this.target = mapper; } diff --git a/java/org/apache/el/lang/FunctionMapperImpl.java b/java/org/apache/el/lang/FunctionMapperImpl.java index 0ce51fa..7ca71b4 100644 --- a/java/org/apache/el/lang/FunctionMapperImpl.java +++ b/java/org/apache/el/lang/FunctionMapperImpl.java @@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentMap; import javax.el.FunctionMapper; +import org.apache.el.util.MessageFactory; import org.apache.el.util.ReflectionUtil; @@ -98,10 +99,10 @@ public class FunctionMapperImpl extends FunctionMapper implements public Function(String prefix, String localName, Method m) { if (localName == null) { - throw new NullPointerException("LocalName cannot be null"); + throw new NullPointerException(MessageFactory.get("error.nullLocalName")); } if (m == null) { - throw new NullPointerException("Method cannot be null"); + throw new NullPointerException(MessageFactory.get("error.nullMethod")); } this.prefix = prefix; this.localName = localName; diff --git a/java/org/apache/el/lang/VariableMapperFactory.java b/java/org/apache/el/lang/VariableMapperFactory.java index 4f6f4dc..3986206 100644 --- a/java/org/apache/el/lang/VariableMapperFactory.java +++ b/java/org/apache/el/lang/VariableMapperFactory.java @@ -20,6 +20,8 @@ package org.apache.el.lang; import javax.el.ValueExpression; import javax.el.VariableMapper; +import org.apache.el.util.MessageFactory; + public class VariableMapperFactory extends VariableMapper { private final VariableMapper target; @@ -27,7 +29,7 @@ public class VariableMapperFactory extends VariableMapper { public VariableMapperFactory(VariableMapper target) { if (target == null) { - throw new NullPointerException("Target VariableMapper cannot be null"); + throw new NullPointerException(MessageFactory.get("error.noVariableMapperTarget")); } this.target = target; } @@ -50,6 +52,6 @@ public class VariableMapperFactory extends VariableMapper { @Override public ValueExpression setVariable(String variable, ValueExpression expression) { - throw new UnsupportedOperationException("Cannot Set Variables on Factory"); + throw new UnsupportedOperationException(MessageFactory.get("error.cannotSetVariables")); } } diff --git a/java/org/apache/el/parser/AstIdentifier.java b/java/org/apache/el/parser/AstIdentifier.java index b6787e2..74deb84 100644 --- a/java/org/apache/el/parser/AstIdentifier.java +++ b/java/org/apache/el/parser/AstIdentifier.java @@ -225,14 +225,9 @@ public final class AstIdentifier extends SimpleNode { if (obj instanceof MethodExpression) { return (MethodExpression) obj; } else if (obj == null) { - throw new MethodNotFoundException("Identity '" + this.image - + "' was null and was unable to invoke"); + throw new MethodNotFoundException(MessageFactory.get("error.identifier.noMethod", this.image)); } else { - throw new ELException( - "Identity '" - + this.image - + "' does not reference a MethodExpression instance, returned type: " - + obj.getClass().getName()); + throw new ELException(MessageFactory.get("error.identifier.notMethodExpression", this.image, obj.getClass().getName())); } } } diff --git a/java/org/apache/el/parser/AstLambdaExpression.java b/java/org/apache/el/parser/AstLambdaExpression.java index 5526b04..f719c33 100644 --- a/java/org/apache/el/parser/AstLambdaExpression.java +++ b/java/org/apache/el/parser/AstLambdaExpression.java @@ -120,7 +120,7 @@ public class AstLambdaExpression extends SimpleNode { private void setNestedState(NestedState nestedState) { if (this.nestedState != null) { // Should never happen - throw new IllegalStateException("nestedState may only be set once"); + throw new IllegalStateException(MessageFactory.get("error.lambda.wrongNestedState")); } this.nestedState = nestedState; diff --git a/java/org/apache/el/parser/AstMethodParameters.java b/java/org/apache/el/parser/AstMethodParameters.java index ed1291c..ffdbd52 100644 --- a/java/org/apache/el/parser/AstMethodParameters.java +++ b/java/org/apache/el/parser/AstMethodParameters.java @@ -19,6 +19,7 @@ package org.apache.el.parser; import java.util.ArrayList; +import java.util.List; import org.apache.el.lang.EvaluationContext; @@ -28,7 +29,7 @@ public final class AstMethodParameters extends SimpleNode { } public Object[] getParameters(EvaluationContext ctx) { - ArrayList<Object> params = new ArrayList<>(); + List<Object> params = new ArrayList<>(); for (int i = 0; i < this.jjtGetNumChildren(); i++) { params.add(this.jjtGetChild(i).getValue(ctx)); } diff --git a/java/org/apache/el/parser/TokenMgrError.java b/java/org/apache/el/parser/TokenMgrError.java index 7fee656..cf37fb9 100644 --- a/java/org/apache/el/parser/TokenMgrError.java +++ b/java/org/apache/el/parser/TokenMgrError.java @@ -106,11 +106,11 @@ public class TokenMgrError extends Error * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + + return "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); + "after : \"" + addEscapes(errorAfter) + "\""; } /** diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java index c2e5931..e4327ba 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -158,12 +158,7 @@ public class ReflectionUtil { } Class<?>[] mParamTypes = m.getParameterTypes(); - int mParamCount; - if (mParamTypes == null) { - mParamCount = 0; - } else { - mParamCount = mParamTypes.length; - } + int mParamCount = mParamTypes.length; // Check the number of parameters // Multiple tests to improve readability --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
