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

commit f6d14bbc764c293c409cc4b03eb0737cd594cacb
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 23 21:07:19 2021 +0100

    JSP API updates required to implement errorOnELNotFound
---
 java/jakarta/servlet/jsp/LocalStrings.properties   | 16 +++++++++++++++
 .../jakarta/servlet/jsp/el/NotFoundELResolver.java | 24 +++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/java/jakarta/servlet/jsp/LocalStrings.properties 
b/java/jakarta/servlet/jsp/LocalStrings.properties
new file mode 100644
index 0000000..2b34d2c
--- /dev/null
+++ b/java/jakarta/servlet/jsp/LocalStrings.properties
@@ -0,0 +1,16 @@
+# 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.
+
+el.unknown.identifier=Unknown identifier
\ No newline at end of file
diff --git a/java/jakarta/servlet/jsp/el/NotFoundELResolver.java 
b/java/jakarta/servlet/jsp/el/NotFoundELResolver.java
index 90fd930..517758f 100644
--- a/java/jakarta/servlet/jsp/el/NotFoundELResolver.java
+++ b/java/jakarta/servlet/jsp/el/NotFoundELResolver.java
@@ -20,9 +20,11 @@ import java.beans.FeatureDescriptor;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Objects;
+import java.util.ResourceBundle;
 
 import jakarta.el.ELContext;
 import jakarta.el.ELResolver;
+import jakarta.el.PropertyNotFoundException;
 
 /**
  * The final resolver of the Jakarta Server Pages ELResolver chain. It always
@@ -32,16 +34,36 @@ import jakarta.el.ELResolver;
  */
 public class NotFoundELResolver extends ELResolver {
 
+    private static final String LSTRING_FILE = 
"jakarta.servlet.jsp.LocalStrings";
+    private static final ResourceBundle lStrings = 
ResourceBundle.getBundle(LSTRING_FILE);
+
     /**
      * {@inheritDoc}
      * <p>
-     * Always resolves the property and always returns {@code null}.
+     * Resolves the property and always returns {@code null} unless the 
provided
+     * context contains a Boolean object with value {@code Boolean.TRUE} as the
+     * value associated with the key
+     * {@code jakarta.servlet.jsp.el.NotFoundELResolver.class} in which case an
+     * exception is thrown. This is to support implementation of the
+     * {@code errorOnELNotFound} page/tag directive.
      *
      * @return Always {@code null}
+     *
+     * @throws PropertyNotFoundException if the provided context contains a
+     *         Boolean object with value {@code Boolean.TRUE} as the value
+     *         associated with the key
+     *         {@code jakarta.servlet.jsp.el.NotFoundELResolver.class}
      */
     @Override
     public Object getValue(ELContext context, Object base, Object property) {
         Objects.requireNonNull(context);
+
+        Object obj = context.getContext(this.getClass());
+        if (obj instanceof Boolean && ((Boolean) obj).booleanValue()) {
+            throw new PropertyNotFoundException(
+                    lStrings.getString("el.unknown.identifier") + " [" + 
property.toString() + "]");
+        }
+
         context.setPropertyResolved(base, property);
         return null;
     }

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

Reply via email to