This is an automated email from the ASF dual-hosted git repository.
csutherl 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 567d4707d1 Fix TestWithoutClustering failure on Java 8
567d4707d1 is described below
commit 567d4707d1cc815bbd554b7aaf45b91ff0d54cd9
Author: Coty Sutherland <[email protected]>
AuthorDate: Fri Aug 14 14:54:35 2026 -0400
Fix TestWithoutClustering failure on Java 8
The StoreConfigIsolatingClassLoader defined classes with a bare
defineClass() call and never defined their package. On Java 8,
Class.getPackage() returns null for classes defined this way, so
StoreRegistry's static initializer (StringManager.getManager(Class))
threw a NullPointerException, surfacing as ExceptionInInitializerError.
Java 9+ defines the package implicitly in defineClass(), which is why
this was only seen on Java 8. Define the package explicitly before
defining the class.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
---
test/org/apache/catalina/startup/TestWithoutClustering.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/test/org/apache/catalina/startup/TestWithoutClustering.java
b/test/org/apache/catalina/startup/TestWithoutClustering.java
index 80b07cf1b9..2cd6656d13 100644
--- a/test/org/apache/catalina/startup/TestWithoutClustering.java
+++ b/test/org/apache/catalina/startup/TestWithoutClustering.java
@@ -410,6 +410,19 @@ public class TestWithoutClustering extends TomcatBaseTest {
try {
byte[] bytes = Files.readAllBytes(
Paths.get(path));
+ // Ensure the package is defined so that
+ // Class.getPackage() does not return null on Java 8.
+ // (Java 9+ defines it implicitly in defineClass().)
+ int lastDot = name.lastIndexOf('.');
+ if (lastDot != -1) {
+ String pkgName = name.substring(0, lastDot);
+ try {
+ definePackage(pkgName, null, null, null,
+ null, null, null, null);
+ } catch (IllegalArgumentException e) {
+ // Package already defined - ignore
+ }
+ }
c = defineClass(name, bytes, 0, bytes.length);
if (resolve) {
resolveClass(c);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]