You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/06/28 11:19:14 UTC

[tomcat] branch main updated: Implement java.util.Optional support for the EL 6.0 API

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 6c8b2d1e0a Implement java.util.Optional support for the EL 6.0 API
6c8b2d1e0a is described below

commit 6c8b2d1e0aeeae2e2a5dda946360ff626bd79ad6
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jun 28 12:18:53 2023 +0100

    Implement java.util.Optional support for the EL 6.0 API
    
    See also:
    https://github.com/jakartaee/expression-language/issues/176
---
 java/jakarta/el/OptionalELResolver.java          | 182 ++++++++++++++++++++
 java/jakarta/el/Util.java                        |   6 +-
 test/jakarta/el/TestOptionalELResolver.java      | 210 +++++++++++++++++++++++
 test/jakarta/el/TestOptionalELResolverInJsp.java |  87 ++++++++++
 test/jakarta/el/TesterBeanA.java                 |  33 ++++
 test/jakarta/el/TesterBeanB.java                 |  35 ++++
 test/webapp/el-optional.jsp                      |  48 ++++++
 webapps/docs/changelog.xml                       |  10 ++
 8 files changed, 609 insertions(+), 2 deletions(-)

diff --git a/java/jakarta/el/OptionalELResolver.java b/java/jakarta/el/OptionalELResolver.java
new file mode 100644
index 0000000000..6f9c3da73f
--- /dev/null
+++ b/java/jakarta/el/OptionalELResolver.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jakarta.el;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Defines property resolution behaviour on {@link Optional}s.
+ *
+ * <p>
+ * This resolver handles base objects that are instances of {@link Optional}.
+ *
+ * <p>
+ * If the {@link Optional#isEmpty()} is {@code true} for the base object and the property is {@code null} then the
+ * resulting value is {@code null}.
+ *
+ * <p>
+ * If the {@link Optional#isEmpty()} is {@code true} for the base object and the property is not {@code null} then the
+ * resulting value is the base object (an empty {@link Optional}).
+ *
+ * <p>
+ * If the {@link Optional#isPresent()} is {@code true} for the base object and the property is {@code null} then the
+ * resulting value is the result of calling {@link Optional#get()} on the base object.
+ *
+ * <p>
+ * If the {@link Optional#isPresent()} is {@code true} for the base object and the property is not {@code null} then the
+ * resulting value is the result of calling {@link ELResolver#getValue(ELContext, Object, Object)} using the
+ * {@link ELResolver} obtained from {@link ELContext#getELResolver()} with the following parameters:
+ * <ul>
+ * <li>The {@link ELContext} is the current context</li>
+ * <li>The base object is the result of calling {@link Optional#get()} on the current base object<li>
+ * <li>The property object is the current property object</li>
+ * </ul>
+ *
+ * <p>
+ * This resolver is always a read-only resolver.
+ */
+public class OptionalELResolver extends ELResolver {
+
+    @Override
+    public Object getValue(ELContext context, Object base, Object property) {
+        Objects.requireNonNull(context);
+
+        if (base instanceof Optional) {
+            context.setPropertyResolved(base, property);
+            if (((Optional<?>) base).isEmpty()) {
+                if (property == null) {
+                    return null;
+                } else {
+                    return base;
+                }
+            } else {
+                if (property == null) {
+                    return ((Optional<?>) base).get();
+                } else {
+                    Object resolvedBase = ((Optional<?>) base).get();
+                    return context.getELResolver().getValue(context, resolvedBase, property);
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * If the base object is an {@link Optional} this method always returns {@code null} since instances of this
+     * resolver are always read-only.
+     */
+    @Override
+    public Class<?> getType(ELContext context, Object base, Object property) {
+        Objects.requireNonNull(context);
+
+        if (base instanceof Optional) {
+            context.setPropertyResolved(base, property);
+        }
+
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * If the base object is an {@link Optional} this method always throws a {@link PropertyNotWritableException} since
+     * instances of this resolver are always read-only.
+     */
+    @Override
+    public void setValue(ELContext context, Object base, Object property, Object value) {
+        Objects.requireNonNull(context);
+
+        if (base instanceof Optional) {
+            throw new PropertyNotWritableException(
+                    Util.message(context, "resolverNotWritable", base.getClass().getName()));
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * If the base object is an {@link Optional} this method always returns {@code true} since instances of this
+     * resolver are always read-only.
+     */
+    @Override
+    public boolean isReadOnly(ELContext context, Object base, Object property) {
+        Objects.requireNonNull(context);
+
+        if (base instanceof Optional) {
+            context.setPropertyResolved(base, property);
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * If the base object is an {@link Optional} this method always returns {@code Object.class}.
+     */
+    @Override
+    public Class<?> getCommonPropertyType(ELContext context, Object base) {
+        if (base instanceof Optional) {
+            return Object.class;
+        }
+
+        return null;
+    }
+
+    @Override
+    public <T> T convertToType(ELContext context, Object obj, Class<T> type) {
+        Objects.requireNonNull(context);
+        if (obj instanceof Optional) {
+            if (((Optional<?>) obj).isPresent()) {
+                Object value = ((Optional<?>) obj).get();
+                // If the value is assignable to the required type, do so.
+                if (type.isAssignableFrom(value.getClass())) {
+                    context.setPropertyResolved(true);
+                    @SuppressWarnings("unchecked")
+                    T result = (T) value;
+                    return result;
+                }
+
+                try {
+                    Object convertedValue = context.convertToType(value, type);
+                    context.setPropertyResolved(true);
+                    @SuppressWarnings("unchecked")
+                    T result = (T) convertedValue;
+                    return result;
+                } catch (ELException e) {
+                    /*
+                     *  TODO: This isn't pretty but it works. Significant refactoring would be required to avoid the
+                     *  exception. See also OptionalELResolver.convertToType().
+                     */
+                }
+            } else {
+                context.setPropertyResolved(true);
+                return null;
+            }
+        }
+        return null;
+    }
+}
diff --git a/java/jakarta/el/Util.java b/java/jakarta/el/Util.java
index 168f89ce42..f44b662063 100644
--- a/java/jakarta/el/Util.java
+++ b/java/jakarta/el/Util.java
@@ -493,8 +493,10 @@ class Util {
      * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync.
      */
     private static boolean isCoercibleFrom(ELContext context, Object src, Class<?> target) {
-        // TODO: This isn't pretty but it works. Significant refactoring would
-        // be required to avoid the exception.
+        /*
+         *  TODO: This isn't pretty but it works. Significant refactoring would be required to avoid the exception. See
+         *        also OptionalELResolver.convertToType().
+         */
         try {
             context.convertToType(src, target);
         } catch (ELException e) {
diff --git a/test/jakarta/el/TestOptionalELResolver.java b/test/jakarta/el/TestOptionalELResolver.java
new file mode 100644
index 0000000000..38b171d3f2
--- /dev/null
+++ b/test/jakarta/el/TestOptionalELResolver.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jakarta.el;
+
+import java.util.Optional;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestOptionalELResolver {
+
+    @Test(expected = PropertyNotFoundException.class)
+    public void testIssue176WithoutOptionalResolverOptionalEmpty() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+
+        TesterBeanA beanA = new TesterBeanA();
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.name}", String.class);
+        ve.getValue(context);
+    }
+
+
+    @Test(expected = PropertyNotFoundException.class)
+    public void testIssue176WithoutOptionalResolverOptionalPresent() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+
+        TesterBeanA beanA = new TesterBeanA();
+        TesterBeanB beanB = new TesterBeanB("test");
+        beanA.setBeanB(beanB);
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.name}", String.class);
+        ve.getValue(context);
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalEmptyWithProperty() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.name}", String.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertNull(result);
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalPresentWithProperty() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+        TesterBeanB beanB = new TesterBeanB("test");
+        beanA.setBeanB(beanB);
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.name}", String.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertEquals("test", result);
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalEmptyWithoutProperty() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt}", TesterBeanB.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertNull(result);
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalPresentWithoutProperty() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+        TesterBeanB beanB = new TesterBeanB("test");
+        beanA.setBeanB(beanB);
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt}", TesterBeanB.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertEquals(beanB, result);
+    }
+
+
+    @Test
+    public void testIssue176WithoutOptionalResolverOptionalEmptyWithMap() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+
+        TesterBeanA beanA = new TesterBeanA();
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.map(b -> b.name)}", Optional.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertNotNull(result);
+        Assert.assertEquals(Optional.class, result.getClass());
+        Assert.assertTrue(((Optional<?>) result).isEmpty());
+    }
+
+
+    @Test
+    public void testIssue176WithoutOptionalResolverOptionalPresentWithMap() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+
+        TesterBeanA beanA = new TesterBeanA();
+        TesterBeanB beanB = new TesterBeanB("test");
+        beanA.setBeanB(beanB);
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.map(b -> b.name)}", Optional.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertNotNull(result);
+        Assert.assertEquals(Optional.class, result.getClass());
+        Assert.assertEquals("test", ((Optional<?>) result).get());
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalEmptyWithMap() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.map(b -> b.name)}", String.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertNull(result);
+    }
+
+
+    @Test
+    public void testIssue176WithOptionalResolverOptionalPresentWithMap() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        StandardELContext context = new StandardELContext(factory);
+        context.addELResolver(new OptionalELResolver());
+
+        TesterBeanA beanA = new TesterBeanA();
+        TesterBeanB beanB = new TesterBeanB("test");
+        beanA.setBeanB(beanB);
+
+        ValueExpression varBeanA = factory.createValueExpression(beanA, TesterBeanA.class);
+        context.getVariableMapper().setVariable("beanA", varBeanA);
+
+        ValueExpression ve = factory.createValueExpression(context, "${beanA.beanBOpt.map(b -> b.name)}", String.class);
+        Object result = ve.getValue(context);
+
+        Assert.assertEquals("test", result);
+    }
+}
diff --git a/test/jakarta/el/TestOptionalELResolverInJsp.java b/test/jakarta/el/TestOptionalELResolverInJsp.java
new file mode 100644
index 0000000000..0b81fa3db0
--- /dev/null
+++ b/test/jakarta/el/TestOptionalELResolverInJsp.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jakarta.el;
+
+import java.io.File;
+
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletContextEvent;
+import jakarta.servlet.ServletContextListener;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.jsp.JspApplicationContext;
+import jakarta.servlet.jsp.JspFactory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+
+public class TestOptionalELResolverInJsp extends TomcatBaseTest {
+
+    @Test
+    public void test() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = new File("test/webapp");
+        Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+        ctx.addApplicationListener(ResolverConfigListener.class.getName());
+
+        tomcat.start();
+
+        ByteChunk responseBody = new ByteChunk();
+        int rc = getUrl("http://localhost:" + getPort() + "/test/el-optional.jsp", responseBody, null);
+
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+        String result = responseBody.toString();
+        assertEcho(result, "00-null");
+        assertEcho(result, "01-null");
+        assertEcho(result, "02-null");
+        assertEcho(result, "10-This is an instance of TesterBeanB");
+        assertEcho(result, "11-test");
+        assertEcho(result, "12-test");
+        assertEcho(result, "20-null");
+        assertEcho(result, "21-null");
+        assertEcho(result, "22-null");
+        assertEcho(result, "30-This is an instance of TesterBeanB");
+        assertEcho(result, "31-test");
+        assertEcho(result, "32-test");
+    }
+
+
+    // Assertion for text contained with <p></p>, e.g. printed by tags:echo
+    private static void assertEcho(String result, String expected) {
+        Assert.assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0);
+    }
+
+
+    public static class ResolverConfigListener implements ServletContextListener {
+
+        @Override
+        public void contextInitialized(ServletContextEvent sce) {
+            ServletContext servletContext = sce.getServletContext();
+            JspFactory jspFactory = JspFactory.getDefaultFactory();
+            JspApplicationContext jspApplicationContext = jspFactory.getJspApplicationContext(servletContext);
+            jspApplicationContext.addELResolver(new OptionalELResolver());
+        }
+    }
+}
diff --git a/test/jakarta/el/TesterBeanA.java b/test/jakarta/el/TesterBeanA.java
new file mode 100644
index 0000000000..97f153a440
--- /dev/null
+++ b/test/jakarta/el/TesterBeanA.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jakarta.el;
+
+import java.util.Optional;
+
+public class TesterBeanA {
+    private TesterBeanB beanB;
+
+    public Optional<TesterBeanB> getBeanBOpt() {
+        return Optional.ofNullable(beanB);
+    }
+
+    public void setBeanB(TesterBeanB beanB) {
+        this.beanB = beanB;
+    }
+}
+
+
diff --git a/test/jakarta/el/TesterBeanB.java b/test/jakarta/el/TesterBeanB.java
new file mode 100644
index 0000000000..66f9de0d4c
--- /dev/null
+++ b/test/jakarta/el/TesterBeanB.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jakarta.el;
+
+public class TesterBeanB {
+
+    private final String name;
+
+    public TesterBeanB(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String toString() {
+        return "This is an instance of TesterBeanB";
+    }
+}
diff --git a/test/webapp/el-optional.jsp b/test/webapp/el-optional.jsp
new file mode 100644
index 0000000000..8fcf3b919d
--- /dev/null
+++ b/test/webapp/el-optional.jsp
@@ -0,0 +1,48 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
+<%@ page import="jakarta.el.TesterBeanA" %>
+<%@ page import="jakarta.el.TesterBeanB" %>
+<html>
+  <head><title>EL method test cases</title></head>
+  <body>
+    <%
+    TesterBeanA beanA1 = new TesterBeanA();
+
+    TesterBeanA beanA2 = new TesterBeanA();
+    TesterBeanB beanB = new TesterBeanB("test");
+    beanA2.setBeanB(beanB);
+
+    pageContext.setAttribute("testBeanA1", beanA1, PageContext.REQUEST_SCOPE);
+    pageContext.setAttribute("testBeanA2", beanA2, PageContext.REQUEST_SCOPE);
+    %>
+
+    <tags:echo echo="00-${testBeanA1.beanBOpt}" />
+    <tags:echo echo="01-${testBeanA1.beanBOpt.name}" />
+    <tags:echo echo="02-${testBeanA1.beanBOpt.map(b -> b.name)}" />
+    <tags:echo echo="10-${testBeanA2.beanBOpt}" />
+    <tags:echo echo="11-${testBeanA2.beanBOpt.name}" />
+    <tags:echo echo="12-${testBeanA2.beanBOpt.map(b -> b.name)}" />
+
+    <tags:echo-deferred echo="20-#{testBeanA1.beanBOpt}" />
+    <tags:echo-deferred echo="21-#{testBeanA1.beanBOpt.name}" />
+    <tags:echo-deferred echo="22-#{testBeanA1.beanBOpt.map(b -> b.name)}" />
+    <tags:echo-deferred echo="30-#{testBeanA2.beanBOpt}" />
+    <tags:echo-deferred echo="31-#{testBeanA2.beanBOpt.name}" />
+    <tags:echo-deferred echo="32-#{testBeanA2.beanBOpt.map(b -> b.name)}" />
+  </body>
+</html>
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 45dc7ce86c..6d58f1ceb2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,16 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <add>
+        Add <code>java.util.Optional</code> support via the
+        <code>jakarta.el.OptionalELResolver</code>  to Tomcat's implementation
+        of the Jakarta EL API to align with the latest proposals for the Jakarta
+        EL 6.0 API. (markt)
+      </add>
+    </changelog>
+  </subsection>
   <subsection name="WebSocket">
     <changelog>
       <fix>


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