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 2019/10/04 16:56:30 UTC

[tomcat] branch 7.0.x updated (8b3cf39 -> b4331ea)

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

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


    from 8b3cf39  Also skip interfaces reported via onStartup()
     new 08a471f  Add a module check when processing the scan for server endpoints
     new b4331ea  Update changelog

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:
 java/org/apache/tomcat/util/compat/Jre9Compat.java | 25 ++++++++++++++++++++++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 13 +++++++++++
 java/org/apache/tomcat/websocket/server/WsSci.java |  8 +++++--
 webapps/docs/changelog.xml                         | 13 +++++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)


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


[tomcat] 02/02: Update changelog

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

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

commit b4331ea14ae601328eff1be855da79a08b7b2b5a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 4 17:49:42 2019 +0100

    Update changelog
---
 webapps/docs/changelog.xml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 0d31739..4028506 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -149,6 +149,15 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <fix>
+        <bug>63781</bug>: When performing various checks related to the
+        visibility of classes, fields an methods in the EL implementation, also
+        check that the containing modeul has been exported. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Web Socket">
     <changelog>
       <fix>


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


[tomcat] 01/02: Add a module check when processing the scan for server endpoints

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

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

commit 08a471f95262c923a2c7860151310cc1cb3dcd65
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 4 17:44:04 2019 +0100

    Add a module check when processing the scan for server endpoints
---
 java/org/apache/tomcat/util/compat/Jre9Compat.java | 25 ++++++++++++++++++++++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 13 +++++++++++
 java/org/apache/tomcat/websocket/server/WsSci.java |  8 +++++--
 webapps/docs/changelog.xml                         |  4 ++++
 4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java
index e8c5c3f..f253f93 100644
--- a/java/org/apache/tomcat/util/compat/Jre9Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java
@@ -54,6 +54,8 @@ class Jre9Compat extends Jre8Compat {
     private static final Object RUNTIME_VERSION;
     private static final int RUNTIME_MAJOR_VERSION;
     private static final Method canAccessMethod;
+    private static final Method getModuleMethod;
+    private static final Method isExportedMethod;
 
     static {
         Class<?> c1 = null;
@@ -70,6 +72,8 @@ class Jre9Compat extends Jre8Compat {
         Object o14 = null;
         Object o15 = null;
         Method m16 = null;
+        Method m17 = null;
+        Method m18 = null;
 
         try {
             // Order is important for the error handling below.
@@ -98,6 +102,9 @@ class Jre9Compat extends Jre8Compat {
             o14 = runtimeVersionMethod.invoke(null);
             o15 = majorMethod.invoke(o14);
             m16 = AccessibleObject.class.getMethod("canAccess", new Class<?>[] { Object.class });
+            m17 = Class.class.getMethod("getModule");
+            Class<?> moduleClass = Class.forName("java.lang.Module");
+            m18 = moduleClass.getMethod("isExported", String.class);
 
         } catch (SecurityException e) {
             // Should never happen
@@ -145,6 +152,8 @@ class Jre9Compat extends Jre8Compat {
         }
 
         canAccessMethod = m16;
+        getModuleMethod = m17;
+        isExportedMethod = m18;
     }
 
 
@@ -256,4 +265,20 @@ class Jre9Compat extends Jre8Compat {
             return false;
         }
     }
+
+
+    @Override
+    public boolean isExported(Class<?> type) {
+        try {
+            String packageName = type.getPackage().getName();
+            Object module = getModuleMethod.invoke(type);
+            return ((Boolean) isExportedMethod.invoke(module, packageName)).booleanValue();
+        } catch (IllegalArgumentException e) {
+            return false;
+        } catch (IllegalAccessException e) {
+            return false;
+        } catch (InvocationTargetException e) {
+            return false;
+        }
+    }
 }
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java
index 9883fc5..b3ba44f 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -362,4 +362,17 @@ public class JreCompat {
         // Java 8 doesn't support modules so default to true
         return true;
     }
+
+
+    /**
+     * Is the given class in an exported package?
+     *
+     * @param type  The class to test
+     *
+     * @return Always {@code true} for Java 8. {@code true} if the enclosing
+     *         package is exported for Java 9+
+     */
+    public boolean isExported(Class<?> type) {
+        return true;
+    }
 }
diff --git a/java/org/apache/tomcat/websocket/server/WsSci.java b/java/org/apache/tomcat/websocket/server/WsSci.java
index 8d8b688..de7e712 100644
--- a/java/org/apache/tomcat/websocket/server/WsSci.java
+++ b/java/org/apache/tomcat/websocket/server/WsSci.java
@@ -34,6 +34,7 @@ import javax.websocket.server.ServerEndpointConfig;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.compat.JreCompat;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -80,11 +81,14 @@ public class WsSci implements ServletContainerInitializer {
             String wsPackage = ContainerProvider.class.getName();
             wsPackage = wsPackage.substring(0, wsPackage.lastIndexOf('.') + 1);
             for (Class<?> clazz : clazzes) {
+                JreCompat jreCompat = JreCompat.getInstance();
                 int modifiers = clazz.getModifiers();
                 if (!Modifier.isPublic(modifiers) ||
                         Modifier.isAbstract(modifiers) ||
-                        Modifier.isInterface(modifiers)) {
-                    // Non-public, abstract or interface - skip it.
+                        Modifier.isInterface(modifiers) ||
+                        !jreCompat.isExported(clazz)) {
+                    // Non-public, abstract, interface or not in an exported
+                    // package (Java 9+) - skip it.
                     continue;
                 }
                 // Protect against scanning the WebSocket API JARs
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 4aba546..0d31739 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -156,6 +156,10 @@
         Socket HTTP upgrade request only contains a port if a non-default port
         is being used. (markt)
       </fix>
+      <fix>
+        When running on Java 9 and above, don't attempt to instantiate WebSocket
+        Endpoints found in modules that are not exported. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">


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