Skip to content

Commit

Permalink
Additional changes to support the length property via ArrayELResolver
Browse files Browse the repository at this point in the history
Fixes some TCK failures (or at least it will once I get the new tests
added to the TCK).
  • Loading branch information
markt-asf committed Jan 15, 2024
1 parent b42a0e5 commit a92a7a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions java/jakarta/el/ArrayELResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public Class<?> getType(ELContext context, Object base, Object property) {

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);
Expand Down Expand Up @@ -95,6 +101,11 @@ public void setValue(ELContext context, Object base, Object property, Object val
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()));
Expand All @@ -116,6 +127,10 @@ public boolean isReadOnly(ELContext context, Object base, Object property) {

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);
Expand Down
10 changes: 9 additions & 1 deletion webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit a92a7a1

Please sign in to comment.