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 2020/01/27 12:26:23 UTC

[tomcat] branch 8.5.x updated (a08ad79 -> ef13eb8)

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

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from a08ad79  Restore constant to avoid unwanted API change
     new 13e1117  Fix BZ 64097 Use ServiceLoader to load EL implementation
     new ef13eb8  Add ServiceLoader entry to META-INF for EL

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build.xml                                          |  3 +-
 java/javax/el/ExpressionFactory.java               | 42 ++++++----------------
 .../services/javax.el.ExpressionFactory            |  3 +-
 .../{jasper.jar => jasper-el.jar}/web-fragment.xml |  6 ++--
 webapps/docs/changelog.xml                         | 10 ++++++
 5 files changed, 27 insertions(+), 37 deletions(-)
 copy java/org/apache/catalina/util/CharsetMapperDefault.properties => res/META-INF/jasper-el.jar/services/javax.el.ExpressionFactory (95%)
 copy res/META-INF/{jasper.jar => jasper-el.jar}/web-fragment.xml (92%)


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


[tomcat] 02/02: Add ServiceLoader entry to META-INF for EL

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ef13eb8fd9962432d244a7aad9cd85998d4cd3b9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jan 27 11:15:01 2020 +0000

    Add ServiceLoader entry to META-INF for EL
---
 build.xml                                          |  3 ++-
 .../services/javax.el.ExpressionFactory            | 16 +++++++++++++
 res/META-INF/jasper-el.jar/web-fragment.xml        | 26 ++++++++++++++++++++++
 webapps/docs/changelog.xml                         |  5 +++++
 4 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/build.xml b/build.xml
index 029b0b8..2121d0b 100644
--- a/build.xml
+++ b/build.xml
@@ -858,7 +858,8 @@
     <!-- Jasper EL Implementation JAR File -->
     <jarIt jarfile="${jasper-el.jar}"
       filesDir="${tomcat.classes}"
-      filesId="files.jasper-el" />
+      filesId="files.jasper-el"
+      meta-inf="${tomcat.manifests}/jasper-el.jar"/>
 
     <!-- Re-packaged Apache Commons DBCP 2-->
     <jarIt jarfile="${tomcat-dbcp.jar}"
diff --git a/res/META-INF/jasper-el.jar/services/javax.el.ExpressionFactory b/res/META-INF/jasper-el.jar/services/javax.el.ExpressionFactory
new file mode 100644
index 0000000..8076bd2
--- /dev/null
+++ b/res/META-INF/jasper-el.jar/services/javax.el.ExpressionFactory
@@ -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.
+
+org.apache.el.ExpressionFactoryImpl
\ No newline at end of file
diff --git a/res/META-INF/jasper-el.jar/web-fragment.xml b/res/META-INF/jasper-el.jar/web-fragment.xml
new file mode 100644
index 0000000..26b2e6c
--- /dev/null
+++ b/res/META-INF/jasper-el.jar/web-fragment.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<web-fragment xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
+                      http://xmlns.jcp.org/xml/ns/javaee/web-fragment_4_0.xsd"
+              version="4.0"
+              metadata-complete="true">
+    <name>org_apache_jasper_el</name>
+    <distributable/>
+</web-fragment>
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e22237c..22c1fc8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -172,6 +172,11 @@
         <code>ExpressionFactory</code> implementations with
         <code>ServiceLoader</code>. (markt)
       </fix>
+      <add>
+        Add a <code>META-INF/services</code> entry to jasper-el.jar so that the
+        Expression Language implementation can be discovered via the services
+        API. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Cluster">


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


[tomcat] 01/02: Fix BZ 64097 Use ServiceLoader to load EL implementation

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 13e1117ab8b7cb389f84ffe4cfa0935af3eeef1b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jan 27 11:14:15 2020 +0000

    Fix BZ 64097 Use ServiceLoader to load EL implementation
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=64097
---
 java/javax/el/ExpressionFactory.java | 42 ++++++++++--------------------------
 webapps/docs/changelog.xml           |  5 +++++
 2 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/java/javax/el/ExpressionFactory.java b/java/javax/el/ExpressionFactory.java
index 9390170..59ee53e 100644
--- a/java/javax/el/ExpressionFactory.java
+++ b/java/javax/el/ExpressionFactory.java
@@ -14,25 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package javax.el;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
+import java.util.ServiceLoader;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.Lock;
@@ -48,9 +46,6 @@ public abstract class ExpressionFactory {
     private static final boolean IS_SECURITY_ENABLED =
         (System.getSecurityManager() != null);
 
-    private static final String SERVICE_RESOURCE_NAME =
-        "META-INF/services/javax.el.ExpressionFactory";
-
     private static final String PROPERTY_NAME = "javax.el.ExpressionFactory";
 
     private static final String PROPERTY_FILE;
@@ -373,35 +368,20 @@ public abstract class ExpressionFactory {
     }
 
     private static String getClassNameServices(ClassLoader tccl) {
-        InputStream is = null;
 
-        if (tccl == null) {
-            is = ClassLoader.getSystemResourceAsStream(SERVICE_RESOURCE_NAME);
-        } else {
-            is = tccl.getResourceAsStream(SERVICE_RESOURCE_NAME);
+        ExpressionFactory result = null;
+
+        ServiceLoader<ExpressionFactory> serviceLoader = ServiceLoader.load(ExpressionFactory.class, tccl);
+        Iterator<ExpressionFactory> iter = serviceLoader.iterator();
+        while (result == null && iter.hasNext()) {
+            result = iter.next();
         }
 
-        if (is != null) {
-            String line = null;
-            try (InputStreamReader isr = new InputStreamReader(is, "UTF-8");
-                    BufferedReader br = new BufferedReader(isr)) {
-                line = br.readLine();
-                if (line != null && line.trim().length() > 0) {
-                    return line.trim();
-                }
-            } catch (UnsupportedEncodingException e) {
-                // Should never happen with UTF-8
-                // If it does - ignore & return null
-            } catch (IOException e) {
-                throw new ELException(Util.message(null, "expressionFactory.readFailed", SERVICE_RESOURCE_NAME), e);
-            } finally {
-                try {
-                    is.close();
-                } catch (IOException ioe) {/*Ignore*/}
-            }
+        if (result == null) {
+            return null;
         }
 
-        return null;
+        return result.getClass().getName();
     }
 
     private static String getClassNameJreDir() {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 364bbc8..e22237c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -167,6 +167,11 @@
         performance optimisation aware of the new public class
         (<code>java.lang.Record</code>) added in Java 14. (markt)
       </fix>
+      <fix>
+        <bug>64097</bug>: Replace the faulty custom services lookup used for
+        <code>ExpressionFactory</code> implementations with
+        <code>ServiceLoader</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">


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