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

markt-asf 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 4e2a298b86 Fix IDE warnings
4e2a298b86 is described below

commit 4e2a298b86f32d8faec09217f53a2fb1f7c91937
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 28 18:19:16 2026 +0000

    Fix IDE warnings
---
 .../org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java |  2 +-
 .../interceptor/TestResetAbandonedTimerStreaming.java   |  1 +
 .../jdbc/pool/interceptor/TestSlowQueryEviction.java    |  2 +-
 .../pool/interceptor/TestSlowQueryJmxMBeanSurface.java  |  6 +++---
 .../pool/interceptor/TestSlowQueryJmxNotifications.java | 10 +++++-----
 .../interceptor/TestStatementCacheJmxCacheSize.java     |  4 ++--
 .../pool/interceptor/TestStatementCacheReconnect.java   | 17 +++++++----------
 .../TestStatementCacheStaleEntryResurrection.java       |  7 +++----
 .../interceptor/TestStatementDecoratorIdentity.java     |  6 +++++-
 .../jdbc/pool/jmx/TestJmxNotificationTypeContract.java  |  2 +-
 10 files changed, 29 insertions(+), 28 deletions(-)

diff --git 
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
 
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
index aabec5de21..9ef3850dc7 100644
--- 
a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
+++ 
b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
@@ -95,7 +95,7 @@ public class ConnectionPool extends 
NotificationBroadcasterSupport
      */
     private static final ThreadPoolExecutor NOTIFIER = new ThreadPoolExecutor(
             0, 1, 60L, TimeUnit.SECONDS,
-            new LinkedBlockingQueue<Runnable>(NOTIFY_QUEUE_CAPACITY),
+            new LinkedBlockingQueue<>(NOTIFY_QUEUE_CAPACITY),
             r -> {
                 Thread t = new Thread(r, "JDBC-Pool-JMX-Notifier");
                 t.setDaemon(true);
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestResetAbandonedTimerStreaming.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestResetAbandonedTimerStreaming.java
index e0df35edf2..b21c2116e0 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestResetAbandonedTimerStreaming.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestResetAbandonedTimerStreaming.java
@@ -251,6 +251,7 @@ class TestResetAbandonedTimerStreaming extends 
JdbcPoolBaseTest {
         assertResultSetHandlesCompose(false);
     }
 
+    @SuppressWarnings("unlikely-arg-type") // Use of unlikely arg-type is 
deliberate
     private void assertResultSetHandlesCompose(boolean useStatementFacade) 
throws SQLException {
         DataSource ds = streamingPool(useStatementFacade);
         Connection con = ds.getConnection();
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryEviction.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryEviction.java
index 8ba701f989..22330b52c3 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryEviction.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryEviction.java
@@ -209,7 +209,7 @@ class TestSlowQueryEviction extends JdbcPoolBaseTest {
         int executed = 5;
         try (Connection c = ds.getConnection()) {
             for (int i = 0; i < prepared; i++) {
-                try (PreparedStatement ps = c.prepareStatement(
+                try (@SuppressWarnings("unused") PreparedStatement ps = 
c.prepareStatement(
                         "SELECT 1 /* prepare-only " + i + " */")) {
                     // never executed, the statement is simply discarded
                 }
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxMBeanSurface.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxMBeanSurface.java
index 40133eb0f3..11109bc49c 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxMBeanSurface.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxMBeanSurface.java
@@ -89,7 +89,7 @@ class TestSlowQueryJmxMBeanSurface extends JdbcPoolBaseTest {
         MBeanServer server = ManagementFactory.getPlatformMBeanServer();
         ObjectName oname = objectNameFor(poolName);
 
-        try (Connection con = ds.getConnection()) {
+        try (@SuppressWarnings("unused") Connection con = ds.getConnection()) {
             Assertions.assertTrue(server.isRegistered(oname),
                     "the interceptor MBean must be registered once the pool is 
in use");
             MBeanInfo info = server.getMBeanInfo(oname);
@@ -132,7 +132,7 @@ class TestSlowQueryJmxMBeanSurface extends JdbcPoolBaseTest 
{
         MBeanServer server = ManagementFactory.getPlatformMBeanServer();
         ObjectName oname = objectNameFor(poolName);
 
-        try (Connection con = reporting.getConnection();
+        try (@SuppressWarnings("unused") Connection con = 
reporting.getConnection();
                 Connection other = statsOnly.getConnection();
                 Statement st = other.createStatement()) {
             st.execute("SELECT 1");
@@ -200,7 +200,7 @@ class TestSlowQueryJmxMBeanSurface extends JdbcPoolBaseTest 
{
         MBeanServer server = ManagementFactory.getPlatformMBeanServer();
         ObjectName oname = objectNameFor(poolName);
 
-        try (Connection ownerCon = owner.getConnection();
+        try (@SuppressWarnings("unused") Connection ownerCon = 
owner.getConnection();
                 Connection sharerCon = sharer.getConnection();
                 Statement st = sharerCon.createStatement()) {
             st.execute("SELECT 1");
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxNotifications.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxNotifications.java
index e64b0a79b7..6eb1615eda 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxNotifications.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestSlowQueryJmxNotifications.java
@@ -412,7 +412,7 @@ class TestSlowQueryJmxNotifications extends 
JdbcPoolBaseTest {
         Obstacle obstacle = new Obstacle();
         server.registerMBean(obstacle, oname);
         try {
-            try (Connection first = ds.getConnection()) {
+            try (@SuppressWarnings("unused") Connection first = 
ds.getConnection()) {
                 // The borrow tried to publish and the MBeanServer refused
                 // it: the name was taken outside the per-name registry, so
                 // registry and MBeanServer now disagree.
@@ -485,8 +485,8 @@ class TestSlowQueryJmxNotifications extends 
JdbcPoolBaseTest {
             // later borrows keep retrying behind the freed slot: still
             // refused (the obstacle holds the name), still no latch, and the
             // identical marker keeps their logging throttled
-            try (Connection second = refusingPool.getConnection();
-                    Connection third = refusingPool.getConnection()) {
+            try (@SuppressWarnings("unused") Connection second = 
refusingPool.getConnection();
+                    @SuppressWarnings("unused") Connection third = 
refusingPool.getConnection()) {
                 Assertions.assertNull(SlowQueryReportJmx.mbeans.get(poolName),
                         "retried refusals must keep leaving the slot free for 
the next borrow");
                 Assertions.assertEquals(oname, 
SlowQueryReportJmx.registrationFailuresLogged.get(poolName),
@@ -525,7 +525,7 @@ class TestSlowQueryJmxNotifications extends 
JdbcPoolBaseTest {
             // and publishes cleanly - success marks nothing in the throttle
             server.unregisterMBean(oname);
             DataSource revivedPool = reportingPoolNamed(poolName);
-            try (Connection borrowed = revivedPool.getConnection()) {
+            try (@SuppressWarnings("unused") Connection borrowed = 
revivedPool.getConnection()) {
                 Assertions.assertTrue(server.isRegistered(oname),
                         "the first borrow of a pool started after the obstacle 
is gone"
                                 + " must publish the MBean");
@@ -614,7 +614,7 @@ class TestSlowQueryJmxNotifications extends 
JdbcPoolBaseTest {
         // merely flagged: a pool restarted under the freed name must be able
         // to re-register, and must release the name again when it closes
         DataSource restarted = reportingPoolNamed(poolName);
-        try (Connection borrowed = restarted.getConnection()) {
+        try (@SuppressWarnings("unused") Connection borrowed = 
restarted.getConnection()) {
             Assertions.assertTrue(server.isRegistered(oname),
                     "a pool started under the concurrently freed name must 
re-register the MBean");
         }
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheJmxCacheSize.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheJmxCacheSize.java
index 2fefd43c9b..35a7b4454f 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheJmxCacheSize.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheJmxCacheSize.java
@@ -122,7 +122,7 @@ class TestStatementCacheJmxCacheSize extends 
JdbcPoolBaseTest {
             Assertions.assertInstanceOf(Integer.class, read,
                     "a monitoring read must yield the number of cached 
statements rather than "
                             + "an object the client can change");
-            Assertions.assertEquals(1, read,
+            Assertions.assertEquals(Integer.valueOf(1), read,
                     "the statement that has just been closed is cached and 
must be counted");
         } finally {
             ds.close();
@@ -191,7 +191,7 @@ class TestStatementCacheJmxCacheSize extends 
JdbcPoolBaseTest {
             // This instance has never been given a pooled connection, so
             // there is no pool whose accounting it could report; 0 would be
             // indistinguishable from an empty cache.
-            Assertions.assertEquals(-1, server.getAttribute(oname, 
"CacheSize"),
+            Assertions.assertEquals(Integer.valueOf(-1), 
server.getAttribute(oname, "CacheSize"),
                     "an interceptor that is not bound to a pooled connection 
must report the "
                             + "documented sentinel instead of a value that 
looks like a count");
         } finally {
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheReconnect.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheReconnect.java
index ade25c605d..42ed0b63f8 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheReconnect.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheReconnect.java
@@ -100,7 +100,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
      * regardless of which path did the replacing, so the helper pins the
      * invariant, not one call site.
      */
-    private void assertCacheDoesNotCrossSessions(DataSource ds, Connection 
second,
+    private void assertCacheDoesNotCrossSessions(Connection second,
             java.sql.Connection oldPhysical, Statement oldStatement, String 
insert,
             int expectedInserts) throws Exception {
         Assertions.assertNull(sessionMarker(second),
@@ -136,8 +136,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
         String insert = "INSERT INTO " + table + " VALUES (?)";
 
         Connection first = ds.getConnection();
-        java.sql.Connection oldPhysical =
-                ((PooledConnection) 
first.unwrap(PooledConnection.class)).getConnection();
+        java.sql.Connection oldPhysical = 
first.unwrap(PooledConnection.class).getConnection();
         setSessionMarker(first, 11);
         PreparedStatement prepared = first.prepareStatement(insert);
         Statement oldStatement = driverStatement(prepared);
@@ -156,7 +155,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
                         + "reach the cache with the purge already done");
         Connection second = ds.getConnection();
         try {
-            assertCacheDoesNotCrossSessions(ds, second, oldPhysical, 
oldStatement, insert, 2);
+            assertCacheDoesNotCrossSessions(second, oldPhysical, oldStatement, 
insert, 2);
         } finally {
             second.close();
         }
@@ -178,8 +177,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
         String insert = "INSERT INTO " + table + " VALUES (?)";
 
         Connection first = ds.getConnection();
-        java.sql.Connection oldPhysical =
-                ((PooledConnection) 
first.unwrap(PooledConnection.class)).getConnection();
+        java.sql.Connection oldPhysical = 
first.unwrap(PooledConnection.class).getConnection();
         setSessionMarker(first, 12);
         PreparedStatement prepared = first.prepareStatement(insert);
         Statement oldStatement = driverStatement(prepared);
@@ -202,7 +200,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
                     CacheAtDisconnectInterceptor.cacheSizeAtDisconnect,
                     "the disconnect walk of the borrow-time reconnect must "
                             + "reach the cache with the purge already done");
-            assertCacheDoesNotCrossSessions(ds, second, oldPhysical, 
oldStatement, insert, 2);
+            assertCacheDoesNotCrossSessions(second, oldPhysical, oldStatement, 
insert, 2);
         } finally {
             second.close();
         }
@@ -224,8 +222,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
         String insert = "INSERT INTO " + table + " VALUES (?)";
 
         Connection first = ds.getConnection();
-        java.sql.Connection oldPhysical =
-                ((PooledConnection) 
first.unwrap(PooledConnection.class)).getConnection();
+        java.sql.Connection oldPhysical = 
first.unwrap(PooledConnection.class).getConnection();
         setSessionMarker(first, 13);
         PreparedStatement prepared = first.prepareStatement(insert);
         Statement oldStatement = driverStatement(prepared);
@@ -250,7 +247,7 @@ class TestStatementCacheReconnect extends JdbcPoolBaseTest {
                         + "cache with the purge already done");
         Connection second = ds.getConnection();
         try {
-            assertCacheDoesNotCrossSessions(ds, second, oldPhysical, 
oldStatement, insert, 2);
+            assertCacheDoesNotCrossSessions(second, oldPhysical, oldStatement, 
insert, 2);
         } finally {
             second.close();
         }
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheStaleEntryResurrection.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheStaleEntryResurrection.java
index 3f9770233a..40f7724014 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheStaleEntryResurrection.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementCacheStaleEntryResurrection.java
@@ -52,7 +52,7 @@ import org.apache.tomcat.jdbc.pool.PooledConnection;
 class TestStatementCacheStaleEntryResurrection extends JdbcPoolBaseTest {
 
     @Test
-    @SuppressWarnings("rawtypes")
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     void anInjectedStaleEntryOfAReplacedSessionIsNotHandedToTheNextBorrower() 
throws Exception {
         DataSource ds = newDataSource();
         ds.getPoolProperties().setJdbcInterceptors(
@@ -67,8 +67,7 @@ class TestStatementCacheStaleEntryResurrection extends 
JdbcPoolBaseTest {
         String insert = "INSERT INTO " + table + " VALUES (?)";
 
         Connection first = ds.getConnection();
-        java.sql.Connection oldPhysical =
-                ((PooledConnection) 
first.unwrap(PooledConnection.class)).getConnection();
+        java.sql.Connection oldPhysical = 
first.unwrap(PooledConnection.class).getConnection();
         setSessionMarker(first, 21);
         PreparedStatement prepared = first.prepareStatement(insert);
         Statement oldDriverStatement = driverStatement(prepared);
@@ -85,7 +84,7 @@ class TestStatementCacheStaleEntryResurrection extends 
JdbcPoolBaseTest {
 
         // Replace the physical session underneath the pooled connection, as
         // any reconnect path does: the purge runs and clears the map.
-        ((PooledConnection) first.unwrap(PooledConnection.class)).reconnect();
+        first.unwrap(PooledConnection.class).reconnect();
         Assertions.assertTrue(oldPhysical.isClosed(),
                 "the replaced session must be closed by the reconnect");
         Assertions.assertEquals(0, cacheMap.size(),
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementDecoratorIdentity.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementDecoratorIdentity.java
index 25523110ec..dcf90537cb 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementDecoratorIdentity.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/interceptor/TestStatementDecoratorIdentity.java
@@ -59,6 +59,7 @@ class TestStatementDecoratorIdentity extends JdbcPoolBaseTest 
{
         return ds;
     }
 
+    @SuppressWarnings("unlikely-arg-type") // Use of unlikely arg-type is 
deliberate
     @Test
     void aStatementHandleIsEqualOnlyToItselfWhileOpen() throws Exception {
         DataSource ds = decoratorPool(false);
@@ -86,6 +87,7 @@ class TestStatementDecoratorIdentity extends JdbcPoolBaseTest 
{
         }
     }
 
+    @SuppressWarnings("unlikely-arg-type") // Use of unlikely arg-type is 
deliberate
     @Test
     void aClosedStatementHandleKeepsAnsweringWithItsOwnIdentity() throws 
Exception {
         DataSource ds = decoratorPool(false);
@@ -117,6 +119,7 @@ class TestStatementDecoratorIdentity extends 
JdbcPoolBaseTest {
         }
     }
 
+    @SuppressWarnings("unlikely-arg-type") // Use of unlikely arg-type is 
deliberate
     @Test
     void aResultSetHandleIsAnHonestHandleOpenAndClosed() throws Exception {
         DataSource ds = decoratorPool(false);
@@ -153,7 +156,7 @@ class TestStatementDecoratorIdentity extends 
JdbcPoolBaseTest {
                         "a closed result set handle must still be equal to 
itself");
                 Assertions.assertEquals(hash, rs.hashCode(),
                         "closing must not change the identity of a handle");
-                Assertions.assertDoesNotThrow(() -> rs.equals(rs),
+                Assertions.assertDoesNotThrow(() -> 
Boolean.valueOf(rs.equals(rs)),
                         "equals on a closed handle must return, not throw");
             }
         }
@@ -201,6 +204,7 @@ class TestStatementDecoratorIdentity extends 
JdbcPoolBaseTest {
      * the configuration switch must not change any answer the application
      * gets.
      */
+    @SuppressWarnings("unlikely-arg-type") // Use of unlikely arg-type is 
deliberate
     @Test
     void bothConfigurationsAnswerTheSameWay() throws Exception {
         for (boolean facade : new boolean[] { false, true }) {
diff --git 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/jmx/TestJmxNotificationTypeContract.java
 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/jmx/TestJmxNotificationTypeContract.java
index 2a6381e215..1b3a92d372 100644
--- 
a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/jmx/TestJmxNotificationTypeContract.java
+++ 
b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/pool/jmx/TestJmxNotificationTypeContract.java
@@ -221,7 +221,7 @@ class TestJmxNotificationTypeContract extends 
JdbcPoolBaseTest {
 
             // Raise POOL EMPTY the way the pool raises it: a failed borrow
             // on an exhausted pool, not a test hand-fed notify().
-            try (Connection held = ds.getConnection()) {
+            try (@SuppressWarnings("unused") Connection held = 
ds.getConnection()) {
                 Assertions.assertThrows(PoolExhaustedException.class, 
ds::getConnection,
                         "a borrow that times out on an exhausted pool must 
fail");
             }


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

Reply via email to