This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new a7b607bc91 Fix a JSP/tag file compilation bug exposed by the test case
for BZ 69635
a7b607bc91 is described below
commit a7b607bc91ed1b2359ba9b185dba6d76f4b3fe33
Author: Mark Thomas <[email protected]>
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 d57303d614..638a3b4e81 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 85267afd78..51fe4e542e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -155,6 +155,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: [email protected]
For additional commands, e-mail: [email protected]