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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new e46996dc1c Fix a JSP/tag file compilation bug exposed by the test case 
for BZ 69635
e46996dc1c is described below

commit e46996dc1c660b16ab1451e38a9efa697fe36021
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue May 6 19:33:59 2025 +0100

    Fix a JSP/tag file compilation bug exposed by the test case for BZ 69635
    
    Tomcat's integration with the JDT compiler could not differentiate
    between the package org.apache.catalina.authenticator and the class
    org.apache.catalina.Authenticator on a case insensitive file system.
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 21 +++++++++++++++------
 webapps/docs/changelog.xml                       |  5 +++++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java 
b/java/org/apache/jasper/compiler/JDTCompiler.java
index 60f5ae4309..9c116a33c0 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -35,6 +35,7 @@ import java.util.Map;
 import java.util.StringTokenizer;
 
 import org.apache.jasper.JasperException;
+import org.apache.jasper.runtime.ExceptionUtils;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.eclipse.jdt.core.compiler.IProblem;
@@ -217,16 +218,24 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
             }
 
             private boolean isPackage(String result) {
+                System.out.println("isPackage(\"" + result + "\")");
                 if (result.equals(targetClassName) || 
result.startsWith(targetClassName + '$')) {
                     return false;
                 }
-                String resourceName = result.replace('.', '/') + ".class";
-                try (InputStream is = 
classLoader.getResourceAsStream(resourceName)) {
-                    return is == null;
-                } catch (IOException e) {
-                    // we are here, since close on is failed. That means it 
was not null
-                    return false;
+                /*
+                 * This might look heavy-weight but, with only the ClassLoader 
API available, trying to load the
+                 * resource as a class is the only reliable way found so far 
to differentiate between a class and a
+                 * package. Other options, such as getResource(), fail for 
some edge cases on case insensitive file
+                 * systems. As this code is only called at compile time, the 
performance impact is not a significant
+                 * concern.
+                 */
+                try {
+                    classLoader.loadClass(result);
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                    return true;
                 }
+                return false;
             }
 
             @Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b7784d0178..800c206e6e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -150,6 +150,11 @@
         activated via JSP servlet param useNonstandardTagOptimizations.
         (jengebr)
       </add>
+      <fix>
+        Fix an edge case compilation bug for JSP and tag files on case
+        insensitive file systems that was exposed by the test case for
+        <bug>69635</bug>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">


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

Reply via email to