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

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new a92a7a1d53 Additional changes to support the length property via 
ArrayELResolver
a92a7a1d53 is described below

commit a92a7a1d53bef0270c9ab96f42f8d424cd884117
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jan 15 17:58:31 2024 +0000

    Additional changes to support the length property via ArrayELResolver
    
    Fixes some TCK failures (or at least it will once I get the new tests
    added to the TCK).
---
 java/jakarta/el/ArrayELResolver.java | 15 +++++++++++++++
 webapps/docs/changelog.xml           | 10 +++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/java/jakarta/el/ArrayELResolver.java 
b/java/jakarta/el/ArrayELResolver.java
index 88176320ed..0f2b77ce5f 100644
--- a/java/jakarta/el/ArrayELResolver.java
+++ b/java/jakarta/el/ArrayELResolver.java
@@ -50,6 +50,12 @@ public class ArrayELResolver extends ELResolver {
 
         if (base != null && base.getClass().isArray()) {
             context.setPropertyResolved(base, property);
+
+            if (LENGTH_PROPERTY_NAME.equals(property)) {
+                // Always read-only
+                return null;
+            }
+
             try {
                 int idx = coerce(property);
                 checkBounds(base, idx);
@@ -95,6 +101,11 @@ public class ArrayELResolver extends ELResolver {
         if (base != null && base.getClass().isArray()) {
             context.setPropertyResolved(base, property);
 
+            if (LENGTH_PROPERTY_NAME.equals(property)) {
+                throw new PropertyNotWritableException(
+                        Util.message(context, "propertyNotWritable", 
base.getClass().getName(), property));
+            }
+
             if (this.readOnly) {
                 throw new PropertyNotWritableException(
                         Util.message(context, "resolverNotWritable", 
base.getClass().getName()));
@@ -116,6 +127,10 @@ public class ArrayELResolver extends ELResolver {
 
         if (base != null && base.getClass().isArray()) {
             context.setPropertyResolved(base, property);
+            if (LENGTH_PROPERTY_NAME.equals(property)) {
+                // Always read-only
+                return true;
+            }
             try {
                 int idx = coerce(property);
                 checkBounds(base, idx);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index aa7fce0034..fbda5cdec1 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -139,6 +139,14 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <fix>
+        Additional fixes to correctly support <code>length</code> as a 
read-only
+        property of an array via the <code>ArrayELResolver</code>. (markt)
+      </fix>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 11.0.0-M16 (markt)" rtext="2024-01-09">
   <subsection name="Catalina">
@@ -1269,7 +1277,7 @@
       <add>
         Align the EL implementation with the latest changes to the Jakarta EL
         specification and add support for the length attribute to the
-        <code>ArrayElResolver</code>. (markt)
+        <code>ArrayELResolver</code>. (markt)
       </add>
     </changelog>
   </subsection>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to