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:51:48 UTC

[tomcat] branch 8.5.x updated (cc78a85 -> fd7de63)

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 cc78a85  Also skip interfaces reported via onStartup()
     new 39e22eb  Add a module check when processing the scan for server endpoints
     new fd7de63  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 | 21 +++++++++++++++++++++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 13 +++++++++++++
 java/org/apache/tomcat/websocket/server/WsSci.java |  9 +++++++--
 webapps/docs/changelog.xml                         | 13 +++++++++++++
 4 files changed, 54 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 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit fd7de63cc67752a87d2e93a1a84b42aaa080bcf1
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 e677098..afab2e9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -63,6 +63,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 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 39e22eb5fb312b41595b557149837d2b024c2787
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 | 21 +++++++++++++++++++++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 13 +++++++++++++
 java/org/apache/tomcat/websocket/server/WsSci.java |  9 +++++++--
 webapps/docs/changelog.xml                         |  4 ++++
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java
index c37652f..11c873e 100644
--- a/java/org/apache/tomcat/util/compat/Jre9Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java
@@ -59,6 +59,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;
@@ -77,6 +79,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.
@@ -107,6 +111,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 (ClassNotFoundException e) {
             if (c1 == null) {
@@ -144,6 +151,8 @@ class Jre9Compat extends Jre8Compat {
         }
 
         canAccessMethod = m16;
+        getModuleMethod = m17;
+        isExportedMethod = m18;
     }
 
 
@@ -253,4 +262,16 @@ 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 (ReflectiveOperationException e) {
+            return false;
+        }
+    }
 }
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java
index d7b78a1..4deb72c 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -231,4 +231,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 6f98f43..6396c60 100644
--- a/java/org/apache/tomcat/websocket/server/WsSci.java
+++ b/java/org/apache/tomcat/websocket/server/WsSci.java
@@ -31,6 +31,8 @@ import javax.websocket.server.ServerApplicationConfig;
 import javax.websocket.server.ServerEndpoint;
 import javax.websocket.server.ServerEndpointConfig;
 
+import org.apache.tomcat.util.compat.JreCompat;
+
 /**
  * Registers an interest in any class that is annotated with
  * {@link ServerEndpoint} so that Endpoint can be published via the WebSocket
@@ -60,11 +62,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 6a57bb9..e677098 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -70,6 +70,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