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

rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit cb3e8099d3e55b67f9f85cda19cc4d0e59ae572a
Author: opencode <[email protected]>
AuthorDate: Wed Oct 28 15:27:10 2026 +0100

    Restore in the jdbc-pool tests the public constructors that reflection 
requires
    
    Commit b541a583ec applied the newly enabled RedundantModifier Checkstyle
    check to the test code and stripped the public modifier from the
    constructors of two nested helper classes, which broke the tests that
    instantiate those helpers reflectively: Class.getConstructor() only
    finds declared public constructors, so the pool's interceptor
    instantiation and the naming resources factory both failed with a
    NoSuchMethodException instead of reaching the intended behavior.
    
    Restore the public modifier on the two constructors and make their
    enclosing test classes public, which is where the RedundantModifier
    check accepts the modifier without suppressing the check: within a
    package-private enclosing class, a public constructor is flagged as
    redundant even though reflection requires it to be declared. The
    constructors keep an explicit comment noting that they must remain
    public. TestJmxRegistration, the third file touched by the same
    commit, builds its MBean instances directly in the same package and
    is unaffected.
---
 .../org/apache/tomcat/jdbc/naming/TestNamingFactory.java  | 15 ++++++++++++---
 .../jdbc/pool/interceptor/TestInterceptorResetOrder.java  |  8 ++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/naming/TestNamingFactory.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/naming/TestNamingFactory.java
index 8e61c923a4..5610f9dac2 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/naming/TestNamingFactory.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/naming/TestNamingFactory.java
@@ -43,7 +43,10 @@ import org.apache.tomcat.jdbc.pool.XADataSource;
  * correctly configured, fully working pool; and the generic naming
  * factory applies documented property types to the configured object.
  */
-class TestNamingFactory extends JdbcPoolBaseTest {
+/* Public because the public nested targets instantiated through reflection
+   must declare public constructors, which Checkstyle's RedundantModifier
+   check only accepts within a public enclosing class. */
+public class TestNamingFactory extends JdbcPoolBaseTest {
 
     private Reference dataSourceReference(String className) {
         Reference ref = new Reference(className, null, null);
@@ -348,9 +351,15 @@ class TestNamingFactory extends JdbcPoolBaseTest {
                 ne.getRootCause());
     }
 
-    /** Target whose no-argument constructor throws. */
+    /**
+     * Target whose no-argument constructor throws. The constructor must
+     * keep its explicit public modifier: the factory locates it with
+     * reflection (Class.getConstructor() only finds declared public
+     * constructors), and the enclosing class is public so Checkstyle's
+     * RedundantModifier check does not treat the modifier as redundant.
+     */
     public static class ThrowingCtorTarget {
-        ThrowingCtorTarget() {
+        public ThrowingCtorTarget() {
             throw new IllegalStateException("boom");
         }
     }
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestInterceptorResetOrder.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestInterceptorResetOrder.java
index 5504b716ea..e7f46d3557 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestInterceptorResetOrder.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestInterceptorResetOrder.java
@@ -37,7 +37,11 @@ import org.apache.tomcat.jdbc.pool.PooledConnection;
  * The interceptors of a connection must be reset in the order in which they 
are declared, whether the connection is
  * new or is taken from the pool, and a failure to reset them must not leave 
the connection borrowed.
  */
-class TestInterceptorResetOrder extends JdbcPoolBaseTest {
+/* Public because the public nested interceptors are instantiated through
+   reflection and must declare public constructors (Class.getConstructor()
+   only finds declared public constructors), which Checkstyle's
+   RedundantModifier check only accepts within a public enclosing class. */
+public class TestInterceptorResetOrder extends JdbcPoolBaseTest {
 
     private static final List<String> RESETS = 
Collections.synchronizedList(new ArrayList<>());
 
@@ -147,7 +151,7 @@ class TestInterceptorResetOrder extends JdbcPoolBaseTest {
 
         static volatile boolean fail;
 
-        Unconstructable() {
+        public Unconstructable() {
             if (fail) {
                 throw new IllegalStateException();
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to