This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new f44fc90faa Fix array exception generating error message after
refactoring
f44fc90faa is described below
commit f44fc90faa0e2326b05c880aa89e0cebf82ca390
Author: remm <[email protected]>
AuthorDate: Fri Feb 6 15:59:57 2026 +0100
Fix array exception generating error message after refactoring
BZ69948, would throw an ArrayOutOfBoundsException instead of a
PropertyNotFoundException.
Based on PR#950 submitted by Jérôme Besnard.
---
java/org/apache/el/parser/AstValue.java | 9 +++-----
test/org/apache/el/TestValueExpressionImpl.java | 30 +++++++++++++++++++++++++
webapps/docs/changelog.xml | 10 +++++++++
3 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/el/parser/AstValue.java
b/java/org/apache/el/parser/AstValue.java
index f1bb087a89..bea041a22e 100644
--- a/java/org/apache/el/parser/AstValue.java
+++ b/java/org/apache/el/parser/AstValue.java
@@ -92,33 +92,30 @@ public final class AstValue extends SimpleNode {
// Method call at end of expression
ctx.setPropertyResolved(false);
property = this.children[i].getValue(ctx);
- i += 2;
-
if (property == null) {
throw new PropertyNotFoundException(
MessageFactory.get("error.unreachable.property",
this.children[i].getImage()));
}
+ i += 2;
} else if (i + 1 < propCount) {
// Object with property not at end of expression
property = this.children[i].getValue(ctx);
ctx.setPropertyResolved(false);
base = resolver.getValue(ctx, base, property);
i++;
-
} else {
// Object with property at end of expression
ctx.setPropertyResolved(false);
property = this.children[i].getValue(ctx);
- i++;
-
if (property == null) {
throw new PropertyNotFoundException(
MessageFactory.get("error.unreachable.property",
this.children[i].getImage()));
}
+ i++;
}
if (base == null) {
throw new PropertyNotFoundException(
- MessageFactory.get("error.unreachable.property",
this.children[i].getImage()));
+ MessageFactory.get("error.unreachable.property",
this.children[propCount - 1].getImage()));
}
}
diff --git a/test/org/apache/el/TestValueExpressionImpl.java
b/test/org/apache/el/TestValueExpressionImpl.java
index a56f569db5..928400e3c8 100644
--- a/test/org/apache/el/TestValueExpressionImpl.java
+++ b/test/org/apache/el/TestValueExpressionImpl.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import jakarta.el.ELContext;
import jakarta.el.ExpressionFactory;
+import jakarta.el.PropertyNotFoundException;
import jakarta.el.ValueExpression;
import jakarta.el.ValueReference;
@@ -327,4 +328,33 @@ public class TestValueExpressionImpl {
Assert.assertNotNull(result);
Assert.assertTrue(result.isEmpty());
}
+
+
+ @Test
+ public void testBug69948() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl(factory);
+
+ TesterBeanEmptyMap beanEmptyMap = new TesterBeanEmptyMap();
+ TesterBeanA beanA = new TesterBeanA();
+ beanA.setName(null);
+
+ ValueExpression var = factory.createValueExpression(beanEmptyMap,
TesterBeanEmptyMap.class);
+ context.getVariableMapper().setVariable("beanEmptyMap", var);
+ var = factory.createValueExpression(beanA, TesterBeanA.class);
+ context.getVariableMapper().setVariable("beanA", var);
+
+
+ ValueExpression ve = factory.createValueExpression(context,
"${beanEmptyMap[beanA.name][beanA.name]}", Object.class);
+
+ Assert.assertThrows(PropertyNotFoundException.class, () ->
ve.getValueReference(context));
+ }
+
+ public static class TesterBeanEmptyMap extends HashMap<Object, Map<String,
Object>> {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public Map<String, Object> get(Object key) {
+ return Collections.emptyMap();
+ }
+ }
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index db49f21a4e..57dd59ed8d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,16 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 10.1.53 (schultz)" rtext="in development">
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>69948</bug>: Avoid ArrayOutOfBoundsException instead of
+ PropertyNotFoundException when generating a properties not found
+ exception in AstValue. Based on <pr>950</pr> submitted by Jérôme
+ Besnard. (remm)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Web applications">
<changelog>
<add>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]