This is an automated email from the ASF dual-hosted git repository. markt-asf pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f86a17d67a8f9d5c7f6cfc0e2c3c7e654e4290f2 Author: Mark Thomas <[email protected]> AuthorDate: Tue Oct 20 17:15:06 2026 +0100 Fix IDE warnings Some reformatting where lines were obviously too long --- test/jakarta/el/TestBeanELResolver.java | 19 ++- test/org/apache/catalina/ssi/TestSSIFsize.java | 3 +- .../TesterServiceWithFailingInitializer.java | 2 +- .../group/interceptors/TestSimpleCoordinator.java | 7 +- .../tribes/membership/TestMcastService.java | 38 +++-- .../tribes/tipis/TestAbstractReplicatedMap.java | 97 ++++++------ .../tribes/tipis/TestLazyReplicatedMap.java | 15 +- .../tribes/transport/TestAbstractSender.java | 23 ++- .../rewrite/TestRandomizedTextRewriteMap.java | 30 ++-- .../http11/filters/TestBufferedInputFilter.java | 2 +- .../apache/coyote/http11/upgrade/TestUpgrade.java | 45 +++--- test/org/apache/el/TestMethodExpressionImpl.java | 3 +- test/org/apache/el/TesterFunctions.java | 2 +- test/org/apache/el/lang/TestELArithmetic.java | 33 ++--- test/org/apache/el/lang/TestELSupport.java | 6 +- test/org/apache/el/parser/TestAstIdentifier.java | 9 +- .../apache/el/stream/TestCollectionOperations.java | 36 ++--- .../apache/jasper/compiler/TestJavaCompiler.java | 2 +- .../apache/jasper/util/TestFastRemovalDequeue.java | 20 +-- .../apache/tomcat/util/TestIntrospectionUtils.java | 1 + .../collections/TestCaseInsensitiveKeyMap.java | 1 + .../util/collections/TestSynchronizedQueue.java | 6 +- .../util/descriptor/tld/TestTldResourcePath.java | 9 +- .../modeler/TestBaseModelMBeanNotifications.java | 2 +- .../apache/tomcat/util/net/jsse/TestPEMFile.java | 43 +++--- .../apache/tomcat/util/scan/TestJarFileUrlJar.java | 2 +- .../tomcat/util/scan/TestJarFileUrlNestedJar.java | 33 +++-- .../util/threads/TestInlineExecutorService.java | 162 +++++++++++---------- .../apache/tomcat/util/threads/TestTaskQueue.java | 2 + .../util/threads/TestThreadPoolExecutor.java | 18 +-- .../websocket/pojo/TestPojoMethodMapping.java | 28 ++-- .../websocket/server/TestWsServerContainer.java | 3 +- 32 files changed, 351 insertions(+), 351 deletions(-) diff --git a/test/jakarta/el/TestBeanELResolver.java b/test/jakarta/el/TestBeanELResolver.java index 6f58e2ac13..69084b8c51 100644 --- a/test/jakarta/el/TestBeanELResolver.java +++ b/test/jakarta/el/TestBeanELResolver.java @@ -454,10 +454,9 @@ public class TestBeanELResolver { } /** - * Tests that a call to a public method on a non-public class, where the - * method is not exposed via a public interface or super class, throws a - * MethodNotFoundException rather than producing a NullPointerException - * from the use of the null result of the method search. + * Tests that a call to a public method on a non-public class, where the method is not exposed via a public + * interface or super class, throws a MethodNotFoundException rather than producing a NullPointerException from the + * use of the null result of the method search. */ @Test(expected = MethodNotFoundException.class) public void testInvokeNonPublicClass01() { @@ -468,8 +467,8 @@ public class TestBeanELResolver { } /** - * Tests the same behaviour as testInvokeNonPublicClass01() for a method - * with parameters, which is resolved via the slower, broader logic. + * Tests the same behaviour as testInvokeNonPublicClass01() for a method with parameters, which is resolved via the + * slower, broader logic. */ @Test(expected = MethodNotFoundException.class) public void testInvokeNonPublicClass02() { @@ -481,8 +480,7 @@ public class TestBeanELResolver { } /** - * Tests that a public method on a non-public class is invoked normally - * when it is exposed via a public interface. + * Tests that a public method on a non-public class is invoked normally when it is exposed via a public interface. */ @Test public void testInvokeNonPublicClass03() { @@ -1011,9 +1009,10 @@ public class TestBeanELResolver { /* - * Deliberately not public. The methods are only accessible via this class - * so, for the purposes of the EL, they are not accessible at all. + * Deliberately not public. The methods are only accessible via this class so, for the purposes of the EL, they are + * not accessible at all. */ + @SuppressWarnings("unused") private static class NonPublicBean { public String getName() { diff --git a/test/org/apache/catalina/ssi/TestSSIFsize.java b/test/org/apache/catalina/ssi/TestSSIFsize.java index bd7e33d9ed..58704a7902 100644 --- a/test/org/apache/catalina/ssi/TestSSIFsize.java +++ b/test/org/apache/catalina/ssi/TestSSIFsize.java @@ -16,7 +16,6 @@ */ package org.apache.catalina.ssi; -import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collection; @@ -41,7 +40,7 @@ public class TestSSIFsize { } - private String formatSize(long size, String format) throws IOException { + private String formatSize(long size, String format) { SSIMediator mediator = new SSIMediator(new TesterSSIExternalResolver(size), 0); mediator.setConfigSizeFmt(format); StringWriter stringWriter = new StringWriter(); diff --git a/test/org/apache/catalina/startup/TesterServiceWithFailingInitializer.java b/test/org/apache/catalina/startup/TesterServiceWithFailingInitializer.java index a99f3a945c..318da9af6a 100644 --- a/test/org/apache/catalina/startup/TesterServiceWithFailingInitializer.java +++ b/test/org/apache/catalina/startup/TesterServiceWithFailingInitializer.java @@ -26,7 +26,7 @@ public class TesterServiceWithFailingInitializer implements ServletContainerInit static { // Force an ExceptionInInitializerError (a LinkageError) when this // class is initialized by Class.forName(name, true, loader). - if (Boolean.TRUE) { + if (true) { throw new IllegalStateException("Test failure in static initializer"); } } diff --git a/test/org/apache/catalina/tribes/group/interceptors/TestSimpleCoordinator.java b/test/org/apache/catalina/tribes/group/interceptors/TestSimpleCoordinator.java index 015381c943..eb80c414e3 100644 --- a/test/org/apache/catalina/tribes/group/interceptors/TestSimpleCoordinator.java +++ b/test/org/apache/catalina/tribes/group/interceptors/TestSimpleCoordinator.java @@ -80,8 +80,8 @@ public class TestSimpleCoordinator { Assert.assertNotNull("The view must be installed", view); Assert.assertEquals("The view holds the remote member and the local member", 2, view.length); Assert.assertSame(view[0], coordinator.getCoordinator()); - Assert.assertEquals("isCoordinator must agree with the view", - local.equals(view[0]), coordinator.isCoordinator()); + Assert.assertEquals("isCoordinator must agree with the view", Boolean.valueOf(local.equals(view[0])), + Boolean.valueOf(coordinator.isCoordinator())); Assert.assertEquals("A single view change must be reported", 1, coordinator.views.size()); Assert.assertSame(view, coordinator.views.get(0)); } @@ -105,7 +105,6 @@ public class TestSimpleCoordinator { Assert.assertFalse("Second install thread did not finish", second.isAlive()); Assert.assertEquals("The view must be installed", 2, coordinator.getView().length); - Assert.assertEquals("Installing the same view concurrently must notify once", - 1, coordinator.views.size()); + Assert.assertEquals("Installing the same view concurrently must notify once", 1, coordinator.views.size()); } } diff --git a/test/org/apache/catalina/tribes/membership/TestMcastService.java b/test/org/apache/catalina/tribes/membership/TestMcastService.java index fa0144b841..b54696b3a5 100644 --- a/test/org/apache/catalina/tribes/membership/TestMcastService.java +++ b/test/org/apache/catalina/tribes/membership/TestMcastService.java @@ -31,13 +31,13 @@ import org.apache.catalina.tribes.io.XByteBuffer; public class TestMcastService { /* - * The shutdown message that stop() broadcasts routinely fails when the network device is down - * or the socket is already broken. That must not skip leaving the multicast group and closing - * the socket, nor prevent the service facade from releasing its implementation. + * The shutdown message that stop() broadcasts routinely fails when the network device is down or the socket is + * already broken. That must not skip leaving the multicast group and closing the socket, nor prevent the service + * facade from releasing its implementation. */ @Test(timeout = 60000) public void testStopWithFailingShutdownSendCompletes() throws Exception { - int base = 40000 + (int) Math.floorMod(System.nanoTime(), 10000); + int base = 40000 + Math.floorMod(System.nanoTime(), 10000); StringBuilder properties = new StringBuilder(); properties.append("mcastAddress=228.0.0.4\n"); properties.append("mcastPort=").append(base).append("\n"); @@ -74,10 +74,9 @@ public class TestMcastService { } /* - * The soTimeout and ttl reported through MBean must reflect the configuration, whether it is - * supplied through the properties file or through the setters. Previously the getters read - * private fields that only the setters wrote, so a property-based configuration that the socket - * did apply was reported as the default 0. + * The soTimeout and ttl reported through MBean must reflect the configuration, whether it is supplied through the + * properties file or through the setters. Previously the getters read private fields that only the setters wrote, + * so a property-based configuration that the socket did apply was reported as the default 0. */ @Test public void testSoTimeoutAndTtlReflectProperties() throws Exception { @@ -113,8 +112,8 @@ public class TestMcastService { } /* - * When neither the properties nor a setter provides a value, the reported soTimeout and ttl - * default to 0, as they did before. + * When neither the properties nor a setter provides a value, the reported soTimeout and ttl default to 0, as they + * did before. */ @Test public void testSoTimeoutAndTtlDefaultToZero() throws Exception { @@ -124,9 +123,9 @@ public class TestMcastService { } /* - * A non-positive send frequency makes the sender spin sending pings without a pause, and a - * non-positive drop time expires every member on every cycle. Such configuration must be - * rejected when the service starts, before any socket or thread is created. + * A non-positive send frequency makes the sender spin sending pings without a pause, and a non-positive drop time + * expires every member on every cycle. Such configuration must be rejected when the service starts, before any + * socket or thread is created. */ @Test public void testStartRejectsNonPositiveTimingProperties() throws Exception { @@ -161,13 +160,13 @@ public class TestMcastService { } /* - * The 65535 byte protocol limit of an IP packet includes the IP and UDP headers, so a - * broadcast that fits within it can still exceed what the socket is able to send. Such a - * broadcast must be rejected by the size check rather than fail later in the send. + * The 65535 byte protocol limit of an IP packet includes the IP and UDP headers, so a broadcast that fits within it + * can still exceed what the socket is able to send. Such a broadcast must be rejected by the size check rather than + * fail later in the send. */ @Test(timeout = 60000) public void testBroadcastRejectsPacketsTheSocketCannotCarry() throws Exception { - int base = 40000 + (int) Math.floorMod(System.nanoTime(), 10000); + int base = 40000 + Math.floorMod(System.nanoTime(), 10000); Properties props = new Properties(); props.setProperty("mcastAddress", "228.0.0.4"); props.setProperty("mcastPort", String.valueOf(base)); @@ -196,9 +195,8 @@ public class TestMcastService { int overhead = XByteBuffer.createDataPackage(probe).length; Assert.assertTrue(overhead > 0 && overhead < 128); byte[] messageBytes = new byte[McastServiceImpl.MAX_SEND_SIZE + 8 - overhead]; - Assert.assertEquals(McastServiceImpl.MAX_SEND_SIZE + 8, - XByteBuffer.createDataPackage(new ChannelData(probe.getUniqueId(), - new XByteBuffer(messageBytes, false), 0)).length); + Assert.assertEquals(McastServiceImpl.MAX_SEND_SIZE + 8, XByteBuffer.createDataPackage( + new ChannelData(probe.getUniqueId(), new XByteBuffer(messageBytes, false), 0)).length); ChannelData message = new ChannelData(); message.setMessage(new XByteBuffer(messageBytes, false)); diff --git a/test/org/apache/catalina/tribes/tipis/TestAbstractReplicatedMap.java b/test/org/apache/catalina/tribes/tipis/TestAbstractReplicatedMap.java index 24b0f48d0a..7dfd9c28ed 100644 --- a/test/org/apache/catalina/tribes/tipis/TestAbstractReplicatedMap.java +++ b/test/org/apache/catalina/tribes/tipis/TestAbstractReplicatedMap.java @@ -41,8 +41,8 @@ import org.apache.catalina.tribes.tipis.AbstractReplicatedMap.MapMessage; public class TestAbstractReplicatedMap { /* - * The channel resolves any looked up member directly, so that a member can be added to the map - * members without starting a channel. + * The channel resolves any looked up member directly, so that a member can be added to the map members without + * starting a channel. */ private static final class TestChannel extends GroupChannel { @@ -61,8 +61,8 @@ public class TestAbstractReplicatedMap { } /* - * A value whose first serialization blocks until it is released, to simulate the long lasting - * serialization of a full map content. + * A value whose first serialization blocks until it is released, to simulate the long lasting serialization of a + * full map content. */ private static final class BlockingValue implements Serializable { @@ -92,8 +92,8 @@ public class TestAbstractReplicatedMap { } /* - * Whether another thread could enter the given monitor while the current thread stays inside - * the operation that is expected to run outside of that monitor. + * Whether another thread could enter the given monitor while the current thread stays inside the operation that is + * expected to run outside of that monitor. */ private static boolean monitorAvailable(Object monitor, long timeoutMs) { CountDownLatch acquired = new CountDownLatch(1); @@ -113,9 +113,9 @@ public class TestAbstractReplicatedMap { } /* - * The expiry handling of the ping aborts the entries of a timed out member, which sends to the - * remaining members and may block until they acknowledge. It must not run while holding the - * map members lock, since every session operation needs that lock. + * The expiry handling of the ping aborts the entries of a timed out member, which sends to the remaining members + * and may block until they acknowledge. It must not run while holding the map members lock, since every session + * operation needs that lock. */ @Test public void testPingExpiresOutsideMapMembersLock() throws Exception { @@ -123,10 +123,9 @@ public class TestAbstractReplicatedMap { AtomicInteger disappeared = new AtomicInteger(); AtomicBoolean lockAvailable = new AtomicBoolean(); - LazyReplicatedMap<String,String> map = new LazyReplicatedMap<String,String>( - (key, value) -> { - // Not made primary here - }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null) { + LazyReplicatedMap<String,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null) { @Override public void memberDisappeared(Member disappearedMember) { @@ -145,9 +144,9 @@ public class TestAbstractReplicatedMap { } /* - * Adding a member selects backups for the primary entries that have none, which blocks until - * the selected backups acknowledge. That must not run while holding the state lock, since the - * state transfer of joining members needs that lock. + * Adding a member selects backups for the primary entries that have none, which blocks until the selected backups + * acknowledge. That must not run while holding the state lock, since the state transfer of joining members needs + * that lock. */ @Test public void testMapMemberAddedPublishesOutsideStateLock() throws Exception { @@ -155,10 +154,9 @@ public class TestAbstractReplicatedMap { AtomicBoolean lockAvailable = new AtomicBoolean(); AtomicInteger published = new AtomicInteger(); - LazyReplicatedMap<String,String> map = new LazyReplicatedMap<String,String>( - (key, value) -> { - // Not made primary here - }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null) { + LazyReplicatedMap<String,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null) { @Override protected Member[] publishEntryInfo(Object key, Object value) { @@ -180,19 +178,17 @@ public class TestAbstractReplicatedMap { } /* - * Answering a state request serializes the whole map content, which must not happen while - * holding the state lock, since it blocks the state transfer of other joining members for the - * duration of that serialization. + * Answering a state request serializes the whole map content, which must not happen while holding the state lock, + * since it blocks the state transfer of other joining members for the duration of that serialization. */ @Test public void testStateRequestSerializesOutsideStateLock() throws Exception { CountDownLatch release = new CountDownLatch(1); BlockingValue value = new BlockingValue(release); - LazyReplicatedMap<String,BlockingValue> map = new LazyReplicatedMap<String,BlockingValue>( - (key, val) -> { - // Not made primary here - }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); + LazyReplicatedMap<String,BlockingValue> map = new LazyReplicatedMap<>((key, val) -> { + // Not made primary here + }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); map.put("key", value); MapMessage stateRequest = new MapMessage("TestAbstractReplicatedMap".getBytes(StandardCharsets.UTF_8), @@ -222,18 +218,16 @@ public class TestAbstractReplicatedMap { } /* - * The put silently accepts keys that cannot be replicated, so the remove must not fail on such - * a key either, but just skip the notification to the other members. The removal previously - * threw an unchecked exception from the message construction, which also escaped a put that - * replaced such an entry before the new value was stored. + * The put silently accepts keys that cannot be replicated, so the remove must not fail on such a key either, but + * just skip the notification to the other members. The removal previously threw an unchecked exception from the + * message construction, which also escaped a put that replaced such an entry before the new value was stored. */ @Test public void testRemoveNonSerializableKeySkipsNotification() throws Exception { TestChannel channel = new TestChannel(); - LazyReplicatedMap<Object,String> map = new LazyReplicatedMap<Object,String>( - (key, value) -> { - // Not made primary here - }, channel, 1000, "TestAbstractReplicatedMap", null); + LazyReplicatedMap<Object,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, channel, 1000, "TestAbstractReplicatedMap", null); map.memberAlive(new MemberImpl("localhost", 4016, -1)); Object key = new Object(); @@ -245,16 +239,15 @@ public class TestAbstractReplicatedMap { } /* - * A put stores an entry with a null value, so the size must count it like the entry and key - * views do. The size previously filtered such an entry out, breaking the map contract that the - * size equals the size of the entry set, and the isEmpty inherited the inconsistency. + * A put stores an entry with a null value, so the size must count it like the entry and key views do. The size + * previously filtered such an entry out, breaking the map contract that the size equals the size of the entry set, + * and the isEmpty inherited the inconsistency. */ @Test public void testSizeCountsActiveEntriesWithNullValue() throws Exception { - LazyReplicatedMap<String,String> map = new LazyReplicatedMap<String,String>( - (key, value) -> { - // Not made primary here - }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); + LazyReplicatedMap<String,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); map.put("key", "value"); map.put("other", null); @@ -288,24 +281,22 @@ public class TestAbstractReplicatedMap { } /* - * A received backup request carries its key only in serialized form. The reply must deserialize - * that key with the loaders of the map, like the other receive paths do, and must fail the - * request without throwing when the key cannot be deserialized, so that the requester gets a - * normal timeout instead of being answered by a failure of the responder. + * A received backup request carries its key only in serialized form. The reply must deserialize that key with the + * loaders of the map, like the other receive paths do, and must fail the request without throwing when the key + * cannot be deserialized, so that the requester gets a normal timeout instead of being answered by a failure of the + * responder. */ @Test public void testBackupRequestDeserializesKeyOfReceivedMessage() throws Exception { - LazyReplicatedMap<Object,String> map = new LazyReplicatedMap<Object,String>( - (key, value) -> { - // Not made primary here - }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); + LazyReplicatedMap<Object,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, new TestChannel(), 1000, "TestAbstractReplicatedMap", null); map.put(new SerialKey("key"), "value"); Member sender = new MemberImpl("localhost", 4017, -1); // Round trip over the serialization to get a message with the key data but no live key - byte[] wire = XByteBuffer.serialize(new MapMessage( - "TestAbstractReplicatedMap".getBytes(StandardCharsets.UTF_8), MapMessage.MSG_RETRIEVE_BACKUP, false, - new SerialKey("key"), null, null, null, null)); + byte[] wire = XByteBuffer.serialize(new MapMessage("TestAbstractReplicatedMap".getBytes(StandardCharsets.UTF_8), + MapMessage.MSG_RETRIEVE_BACKUP, false, new SerialKey("key"), null, null, null, null)); MapMessage received = (MapMessage) XByteBuffer.deserialize(wire); Serializable reply = map.replyRequest(received, sender); diff --git a/test/org/apache/catalina/tribes/tipis/TestLazyReplicatedMap.java b/test/org/apache/catalina/tribes/tipis/TestLazyReplicatedMap.java index f6cc37fec2..29287c9414 100644 --- a/test/org/apache/catalina/tribes/tipis/TestLazyReplicatedMap.java +++ b/test/org/apache/catalina/tribes/tipis/TestLazyReplicatedMap.java @@ -26,10 +26,10 @@ import org.apache.catalina.tribes.membership.MemberImpl; public class TestLazyReplicatedMap { /* - * The backup node selection snapshots the members and computes an index against the current - * members in two steps. A member added in between lets the index point behind the end of the - * snapshot, which aborted the publication with an array index out of bounds exception, losing - * the entry that was being stored. The index must fall back to the start of the snapshot. + * The backup node selection snapshots the members and computes an index against the current members in two steps. A + * member added in between lets the index point behind the end of the snapshot, which aborted the publication with + * an array index out of bounds exception, losing the entry that was being stored. The index must fall back to the + * start of the snapshot. */ @Test public void testBackupIndexBeyondMemberSnapshotFallsBack() throws Exception { @@ -37,10 +37,9 @@ public class TestLazyReplicatedMap { // A member added between the two steps of the selection, shown directly: one member in // the snapshot, an index computed for a member list that has meanwhile grown - LazyReplicatedMap<String,String> map = new LazyReplicatedMap<String,String>( - (key, value) -> { - // Not made primary here - }, new GroupChannel(), 1000, "TestLazyReplicatedMap", null) { + LazyReplicatedMap<String,String> map = new LazyReplicatedMap<>((key, value) -> { + // Not made primary here + }, new GroupChannel(), 1000, "TestLazyReplicatedMap", null) { @Override public Member[] getMapMembers() { diff --git a/test/org/apache/catalina/tribes/transport/TestAbstractSender.java b/test/org/apache/catalina/tribes/transport/TestAbstractSender.java index 2c93f2fb96..45f3683aa1 100644 --- a/test/org/apache/catalina/tribes/transport/TestAbstractSender.java +++ b/test/org/apache/catalina/tribes/transport/TestAbstractSender.java @@ -78,19 +78,26 @@ public class TestAbstractSender { Assert.assertEquals("txBufSize", expected.getTxBufSize(), actual.getTxBufSize()); Assert.assertEquals("udpRxBufSize", expected.getUdpRxBufSize(), actual.getUdpRxBufSize()); Assert.assertEquals("udpTxBufSize", expected.getUdpTxBufSize(), actual.getUdpTxBufSize()); - Assert.assertEquals("directBuffer", expected.getDirectBuffer(), actual.getDirectBuffer()); + Assert.assertEquals("directBuffer", Boolean.valueOf(expected.getDirectBuffer()), + Boolean.valueOf(actual.getDirectBuffer())); Assert.assertEquals("keepAliveCount", expected.getKeepAliveCount(), actual.getKeepAliveCount()); Assert.assertEquals("keepAliveTime", expected.getKeepAliveTime(), actual.getKeepAliveTime()); Assert.assertEquals("timeout", expected.getTimeout(), actual.getTimeout()); Assert.assertEquals("maxRetryAttempts", expected.getMaxRetryAttempts(), actual.getMaxRetryAttempts()); - Assert.assertEquals("tcpNoDelay", expected.getTcpNoDelay(), actual.getTcpNoDelay()); - Assert.assertEquals("soKeepAlive", expected.getSoKeepAlive(), actual.getSoKeepAlive()); - Assert.assertEquals("ooBInline", expected.getOoBInline(), actual.getOoBInline()); - Assert.assertEquals("soReuseAddress", expected.getSoReuseAddress(), actual.getSoReuseAddress()); - Assert.assertEquals("soLingerOn", expected.getSoLingerOn(), actual.getSoLingerOn()); + Assert.assertEquals("tcpNoDelay", Boolean.valueOf(expected.getTcpNoDelay()), + Boolean.valueOf(actual.getTcpNoDelay())); + Assert.assertEquals("soKeepAlive", Boolean.valueOf(expected.getSoKeepAlive()), + Boolean.valueOf(actual.getSoKeepAlive())); + Assert.assertEquals("ooBInline", Boolean.valueOf(expected.getOoBInline()), + Boolean.valueOf(actual.getOoBInline())); + Assert.assertEquals("soReuseAddress", Boolean.valueOf(expected.getSoReuseAddress()), + Boolean.valueOf(actual.getSoReuseAddress())); + Assert.assertEquals("soLingerOn", Boolean.valueOf(expected.getSoLingerOn()), + Boolean.valueOf(actual.getSoLingerOn())); Assert.assertEquals("soLingerTime", expected.getSoLingerTime(), actual.getSoLingerTime()); Assert.assertEquals("soTrafficClass", expected.getSoTrafficClass(), actual.getSoTrafficClass()); - Assert.assertEquals("throwOnFailedAck", expected.getThrowOnFailedAck(), actual.getThrowOnFailedAck()); - Assert.assertEquals("udpBased", expected.isUdpBased(), actual.isUdpBased()); + Assert.assertEquals("throwOnFailedAck", Boolean.valueOf(expected.getThrowOnFailedAck()), + Boolean.valueOf(actual.getThrowOnFailedAck())); + Assert.assertEquals("udpBased", Boolean.valueOf(expected.isUdpBased()), Boolean.valueOf(actual.isUdpBased())); } } diff --git a/test/org/apache/catalina/valves/rewrite/TestRandomizedTextRewriteMap.java b/test/org/apache/catalina/valves/rewrite/TestRandomizedTextRewriteMap.java index 68aa20b1e1..c866296646 100644 --- a/test/org/apache/catalina/valves/rewrite/TestRandomizedTextRewriteMap.java +++ b/test/org/apache/catalina/valves/rewrite/TestRandomizedTextRewriteMap.java @@ -37,16 +37,14 @@ public class TestRandomizedTextRewriteMap { @Test public void testSingleSpaceSeparation() throws Exception { - RandomizedTextRewriteMap map = - new RandomizedTextRewriteMap(createMapFile("key value\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key value\n"), false); Assert.assertEquals("value", map.lookup("key")); } @Test public void testTabSeparation() throws Exception { // mod_rewrite separates key and value by any whitespace - RandomizedTextRewriteMap map = - new RandomizedTextRewriteMap(createMapFile("key\tvalue\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key\tvalue\n"), false); Assert.assertEquals("value", map.lookup("key")); } @@ -54,15 +52,13 @@ public class TestRandomizedTextRewriteMap { public void testMultipleWhitespaceSeparation() throws Exception { // A single space was required before, which silently added the extra // whitespace to the start of the value - RandomizedTextRewriteMap map = - new RandomizedTextRewriteMap(createMapFile("key \tvalue\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key \tvalue\n"), false); Assert.assertEquals("value", map.lookup("key")); } @Test public void testWhitespaceAroundEntry() throws Exception { - RandomizedTextRewriteMap map = new RandomizedTextRewriteMap( - createMapFile(" key value \n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile(" key value \n"), false); Assert.assertEquals("value", map.lookup("key")); } @@ -70,29 +66,25 @@ public class TestRandomizedTextRewriteMap { public void testIndentedCommentLine() throws Exception { // An indentation before the comment marker used to make the line // look like an entry without a value and fail the map start up - RandomizedTextRewriteMap map = new RandomizedTextRewriteMap( - createMapFile(" # comment\nkey value\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile(" # comment\nkey value\n"), false); Assert.assertEquals("value", map.lookup("key")); } @Test public void testCommentAfterValue() throws Exception { - RandomizedTextRewriteMap map = new RandomizedTextRewriteMap( - createMapFile("key value # comment\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key value # comment\n"), false); Assert.assertEquals("value", map.lookup("key")); } @Test public void testValueMayContainWhitespace() throws Exception { - RandomizedTextRewriteMap map = new RandomizedTextRewriteMap( - createMapFile("key one two\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key one two\n"), false); Assert.assertEquals("one two", map.lookup("key")); } @Test public void testRandomValues() throws Exception { - RandomizedTextRewriteMap map = new RandomizedTextRewriteMap( - createMapFile("key one|two\n"), true); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key one|two\n"), true); Set<String> possible = new HashSet<>(); Set<String> seen = new HashSet<>(); possible.add("one"); @@ -109,15 +101,15 @@ public class TestRandomizedTextRewriteMap { @Test public void testUnknownKeyResolvesToNull() throws Exception { - RandomizedTextRewriteMap map = - new RandomizedTextRewriteMap(createMapFile("key value\n"), false); + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key value\n"), false); Assert.assertNull(map.lookup("other")); } @Test public void testLineWithoutValueThrows() throws Exception { try { - new RandomizedTextRewriteMap(createMapFile("key\n"), false); + @SuppressWarnings("unused") + RandomizedTextRewriteMap map = new RandomizedTextRewriteMap(createMapFile("key\n"), false); Assert.fail("IAE expected."); } catch (IllegalArgumentException e) { // expected, an entry without a value is invalid diff --git a/test/org/apache/coyote/http11/filters/TestBufferedInputFilter.java b/test/org/apache/coyote/http11/filters/TestBufferedInputFilter.java index 03954c5dfb..e0b3b50421 100644 --- a/test/org/apache/coyote/http11/filters/TestBufferedInputFilter.java +++ b/test/org/apache/coyote/http11/filters/TestBufferedInputFilter.java @@ -69,7 +69,7 @@ public class TestBufferedInputFilter { * belong to the body of this request. */ @Test - public void testAvailableWithEmptyBody() throws IOException { + public void testAvailableWithEmptyBody() { BufferedInputFilter filter = new BufferedInputFilter(-1); filter.setLimit(1024); // The body is empty but the downstream buffer has data, for example diff --git a/test/org/apache/coyote/http11/upgrade/TestUpgrade.java b/test/org/apache/coyote/http11/upgrade/TestUpgrade.java index a4123072ed..abbf0cf9de 100644 --- a/test/org/apache/coyote/http11/upgrade/TestUpgrade.java +++ b/test/org/apache/coyote/http11/upgrade/TestUpgrade.java @@ -154,7 +154,6 @@ public class TestUpgrade extends TomcatBaseTest { } @Test - @SuppressWarnings("unchecked") public void testNoCallbacksAfterError() throws Exception { SocketWrapperBase<?> socketWrapper = EasyMock.createMock(SocketWrapperBase.class); ReadListener listener = EasyMock.createMock(ReadListener.class); @@ -177,24 +176,24 @@ public class TestUpgrade extends TomcatBaseTest { socketWrapper.registerReadInterest(); // The first call reports an error. No further socket state check or // listener call-back may occur once the error has been reported. - EasyMock.expect(socketWrapper.isReadyForRead()).andThrow(error); + EasyMock.expect(Boolean.valueOf(socketWrapper.isReadyForRead())).andThrow(error); listener.onError(error); EasyMock.expectLastCall().once(); EasyMock.replay(socketWrapper, listener); - UpgradeServletInputStream sis = new UpgradeServletInputStream(processor, socketWrapper, - new UpgradeInfo()); - sis.setReadListener(listener); + try (UpgradeServletInputStream sis = new UpgradeServletInputStream(processor, socketWrapper, + new UpgradeInfo())) { + sis.setReadListener(listener); - sis.onDataAvailable(); - sis.onDataAvailable(); + sis.onDataAvailable(); + sis.onDataAvailable(); - EasyMock.verify(socketWrapper, listener); + EasyMock.verify(socketWrapper, listener); + } } @Test - @SuppressWarnings("unchecked") public void testWriteErrorReportedOnlyOnce() throws Exception { SocketWrapperBase<?> socketWrapper = EasyMock.createMock(SocketWrapperBase.class); WriteListener listener = EasyMock.createMock(WriteListener.class); @@ -218,27 +217,27 @@ public class TestUpgrade extends TomcatBaseTest { // The flush fails. That failure is seen twice, once by the caller and // once by the close that reports the error. The listener must only be // notified once. - EasyMock.expect(socketWrapper.flush(false)).andThrow(error); - EasyMock.expect(socketWrapper.flush(false)).andThrow(error); + EasyMock.expect(Boolean.valueOf(socketWrapper.flush(false))).andThrow(error); + EasyMock.expect(Boolean.valueOf(socketWrapper.flush(false))).andThrow(error); listener.onError(error); EasyMock.expectLastCall().once(); EasyMock.replay(socketWrapper, listener); - UpgradeServletOutputStream sos = new UpgradeServletOutputStream(processor, socketWrapper, - new UpgradeInfo()); - sos.setWriteListener(listener); + try (UpgradeServletOutputStream sos = new UpgradeServletOutputStream(processor, socketWrapper, + new UpgradeInfo())) { + sos.setWriteListener(listener); - sos.onWritePossible(); - // The call-back for the next dispatch must not trigger any further - // socket processing. - sos.onWritePossible(); + sos.onWritePossible(); + // The call-back for the next dispatch must not trigger any further + // socket processing. + sos.onWritePossible(); - EasyMock.verify(socketWrapper, listener); + EasyMock.verify(socketWrapper, listener); + } } @Test - @SuppressWarnings("unchecked") public void testOnAllDataReadReportedOnlyOnce() throws Exception { SocketWrapperBase<?> socketWrapper = EasyMock.createMock(SocketWrapperBase.class); @@ -260,9 +259,9 @@ public class TestUpgrade extends TomcatBaseTest { // call-back must only be reported once, even if further dispatches // occur. socketWrapper.registerReadInterest(); - EasyMock.expect(socketWrapper.isReadyForRead()).andReturn(Boolean.TRUE); - EasyMock.expect(socketWrapper.read(EasyMock.eq(false), EasyMock.anyObject(byte[].class), - EasyMock.anyInt(), EasyMock.anyInt())).andReturn(-1); + EasyMock.expect(Boolean.valueOf(socketWrapper.isReadyForRead())).andReturn(Boolean.TRUE); + EasyMock.expect(Integer.valueOf(socketWrapper.read(EasyMock.eq(false), EasyMock.anyObject(byte[].class), + EasyMock.anyInt(), EasyMock.anyInt()))).andReturn(Integer.valueOf(-1)); EasyMock.replay(socketWrapper); diff --git a/test/org/apache/el/TestMethodExpressionImpl.java b/test/org/apache/el/TestMethodExpressionImpl.java index 76bab3122d..a3bdd130d0 100644 --- a/test/org/apache/el/TestMethodExpressionImpl.java +++ b/test/org/apache/el/TestMethodExpressionImpl.java @@ -19,6 +19,7 @@ package org.apache.el; import java.util.function.Function; import jakarta.el.ELContext; +import jakarta.el.ELManager; import jakarta.el.ELProcessor; import jakarta.el.ExpressionFactory; import jakarta.el.MethodExpression; @@ -764,7 +765,7 @@ public class TestMethodExpressionImpl { elp.defineBean("beanK", bean); ELContext elpContext = elp.getELManager().getELContext(); - MethodExpression me = elp.getELManager().getExpressionFactory().createMethodExpression(elpContext, + MethodExpression me = ELManager.getExpressionFactory().createMethodExpression(elpContext, "${beanK.child.format(beanK.next())}", String.class, null); MethodReference ref = me.getMethodReference(elpContext); diff --git a/test/org/apache/el/TesterFunctions.java b/test/org/apache/el/TesterFunctions.java index c7f1994f5a..a00a7aa676 100644 --- a/test/org/apache/el/TesterFunctions.java +++ b/test/org/apache/el/TesterFunctions.java @@ -49,7 +49,7 @@ public class TesterFunctions { return inputs == null ? -1 : inputs.length; } - public static int varargsLength2(String prefix, String... inputs) { + public static int varargsLength2(@SuppressWarnings("unused") String prefix, String... inputs) { // Distinguishes a null varargs array from an empty one return inputs == null ? -1 : inputs.length; } diff --git a/test/org/apache/el/lang/TestELArithmetic.java b/test/org/apache/el/lang/TestELArithmetic.java index e5aa355feb..8c1d0acbad 100644 --- a/test/org/apache/el/lang/TestELArithmetic.java +++ b/test/org/apache/el/lang/TestELArithmetic.java @@ -27,13 +27,11 @@ import org.junit.Test; public class TestELArithmetic { private static final String a = "1.1"; - private static final BigInteger b = - new BigInteger("1000000000000000000000"); + private static final BigInteger b = new BigInteger("1000000000000000000000"); @Test public void testAdd01() throws Exception { - Assert.assertEquals("1000000000000000000001.1", - String.valueOf(ELArithmetic.add(a, b))); + Assert.assertEquals("1000000000000000000001.1", String.valueOf(ELArithmetic.add(a, b))); } @Test @@ -45,8 +43,7 @@ public class TestELArithmetic { @Test public void testSubtract01() throws Exception { - Assert.assertEquals("-999999999999999999998.9", - String.valueOf(ELArithmetic.subtract(a, b))); + Assert.assertEquals("-999999999999999999998.9", String.valueOf(ELArithmetic.subtract(a, b))); } @Test @@ -58,8 +55,7 @@ public class TestELArithmetic { @Test public void testMultiply01() throws Exception { - Assert.assertEquals("1100000000000000000000.0", - String.valueOf(ELArithmetic.multiply(a, b))); + Assert.assertEquals("1100000000000000000000.0", String.valueOf(ELArithmetic.multiply(a, b))); } @Test @@ -71,8 +67,7 @@ public class TestELArithmetic { @Test public void testDivide01() throws Exception { - Assert.assertEquals("0.0", - String.valueOf(ELArithmetic.divide(a, b))); + Assert.assertEquals("0.0", String.valueOf(ELArithmetic.divide(a, b))); } @Test @@ -84,8 +79,7 @@ public class TestELArithmetic { @Test public void testMod01() throws Exception { - Assert.assertEquals("1.1", - String.valueOf(ELArithmetic.mod(a, b))); + Assert.assertEquals("1.1", String.valueOf(ELArithmetic.mod(a, b))); } @Test @@ -112,8 +106,7 @@ public class TestELArithmetic { @Test public void testBug47371bigDecimal() throws Exception { - Assert.assertEquals(BigDecimal.valueOf(1), - ELArithmetic.add("", BigDecimal.valueOf(1))); + Assert.assertEquals(BigDecimal.valueOf(1), ELArithmetic.add("", BigDecimal.valueOf(1))); } @Test @@ -128,8 +121,7 @@ public class TestELArithmetic { @Test public void testBug47371bigInteger() throws Exception { - Assert.assertEquals(BigInteger.valueOf(0), - ELArithmetic.multiply("", BigInteger.valueOf(1))); + Assert.assertEquals(BigInteger.valueOf(0), ELArithmetic.multiply("", BigInteger.valueOf(1))); } @Test @@ -179,19 +171,18 @@ public class TestELArithmetic { @Test public void testBigIntegerDivByZeroThrowsELException() { - assertELException("divide", - () -> ELArithmetic.divide((Object) BigInteger.ONE, (Object) BigInteger.ZERO)); + assertELException("divide", () -> ELArithmetic.divide((Object) BigInteger.ONE, (Object) BigInteger.ZERO)); } @Test public void testNonFiniteNumberWithBigDecimalThrowsELException() { // The BigDecimal delegate Number coercion uses new BigDecimal(double) which // rejects NaN and Infinity. The failure must surface as ELException. - assertELException("add", () -> ELArithmetic.add((Object) BigDecimal.ONE, (Object) Double.NaN)); + assertELException("add", () -> ELArithmetic.add((Object) BigDecimal.ONE, (Object) Double.valueOf(Double.NaN))); assertELException("add", - () -> ELArithmetic.add((Object) BigDecimal.ONE, (Object) Double.POSITIVE_INFINITY)); + () -> ELArithmetic.add((Object) BigDecimal.ONE, (Object) Double.valueOf(Double.POSITIVE_INFINITY))); assertELException("divide", - () -> ELArithmetic.divide((Object) BigDecimal.ONE, (Object) Double.NEGATIVE_INFINITY)); + () -> ELArithmetic.divide((Object) BigDecimal.ONE, (Object) Double.valueOf(Double.NEGATIVE_INFINITY))); } @Test diff --git a/test/org/apache/el/lang/TestELSupport.java b/test/org/apache/el/lang/TestELSupport.java index 38a485bf76..ba0a62d2ce 100644 --- a/test/org/apache/el/lang/TestELSupport.java +++ b/test/org/apache/el/lang/TestELSupport.java @@ -272,7 +272,7 @@ public class TestELSupport { // Coercing NaN to BigDecimal uses new BigDecimal(double) which rejects the // value. The failure must surface as ELException. try { - ELSupport.compare(null, BigDecimal.ONE, Double.NaN); + ELSupport.compare(null, BigDecimal.ONE, Double.valueOf(Double.NaN)); Assert.fail("An ELException was expected"); } catch (ELException e) { Assert.assertTrue("Unexpected cause: " + e.getCause(), e.getCause() instanceof NumberFormatException); @@ -282,7 +282,7 @@ public class TestELSupport { @Test public void testEqualsBigDecimalWithNonFiniteThrowsELException() { try { - ELSupport.equals(null, BigDecimal.ONE, Double.NaN); + ELSupport.equals(null, BigDecimal.ONE, Double.valueOf(Double.NaN)); Assert.fail("An ELException was expected"); } catch (ELException e) { Assert.assertTrue("Unexpected cause: " + e.getCause(), e.getCause() instanceof NumberFormatException); @@ -292,7 +292,7 @@ public class TestELSupport { @Test public void testCoerceToTypeNonFiniteToBigDecimalThrowsELException() { try { - ELSupport.coerceToType(null, Double.POSITIVE_INFINITY, BigDecimal.class); + ELSupport.coerceToType(null, Double.valueOf(Double.POSITIVE_INFINITY), BigDecimal.class); Assert.fail("An ELException was expected"); } catch (ELException e) { Assert.assertTrue("Unexpected cause: " + e.getCause(), e.getCause() instanceof NumberFormatException); diff --git a/test/org/apache/el/parser/TestAstIdentifier.java b/test/org/apache/el/parser/TestAstIdentifier.java index fb4e4487a6..bb0e750e7b 100644 --- a/test/org/apache/el/parser/TestAstIdentifier.java +++ b/test/org/apache/el/parser/TestAstIdentifier.java @@ -19,6 +19,7 @@ package org.apache.el.parser; import jakarta.el.ELClass; import jakarta.el.ELContext; import jakarta.el.ELException; +import jakarta.el.ELManager; import jakarta.el.ELProcessor; import jakarta.el.ELResolver; import jakarta.el.ExpressionFactory; @@ -60,7 +61,7 @@ public class TestAstIdentifier { // getType() must resolve an imported class, just as getValue() does ELProcessor processor = new ELProcessor(); ELContext context = processor.getELManager().getELContext(); - ValueExpression ve = processor.getELManager().getExpressionFactory().createValueExpression(context, + ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "${Integer}", Object.class); Assert.assertNotNull(ve.getValue(context)); Assert.assertEquals(ELClass.class, ve.getType(context)); @@ -76,7 +77,7 @@ public class TestAstIdentifier { processor.getELManager().getELContext().getImportHandler().importStatic( "java.lang.Integer.MAX_VALUE"); ELContext context = processor.getELManager().getELContext(); - ValueExpression ve = processor.getELManager().getExpressionFactory().createValueExpression(context, + ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "${MAX_VALUE}", Object.class); Assert.assertEquals(Integer.valueOf(Integer.MAX_VALUE), ve.getValue(context)); Assert.assertEquals(Integer.TYPE, ve.getType(context)); @@ -123,7 +124,7 @@ public class TestAstIdentifier { } }); ELContext context = processor.getELManager().getELContext(); - ValueExpression ve = processor.getELManager().getExpressionFactory().createValueExpression(context, + ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "${Integer}", Object.class); Assert.assertEquals("resolved", ve.getValue(context)); Assert.assertEquals(String.class, ve.getType(context)); @@ -136,7 +137,7 @@ public class TestAstIdentifier { // PropertyNotFoundException from getType() ELProcessor processor = new ELProcessor(); ELContext context = processor.getELManager().getELContext(); - ValueExpression ve = processor.getELManager().getExpressionFactory().createValueExpression(context, + ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "${unresolvedName}", Object.class); try { ve.getType(context); diff --git a/test/org/apache/el/stream/TestCollectionOperations.java b/test/org/apache/el/stream/TestCollectionOperations.java index 19689f27d2..dcfefc5c34 100644 --- a/test/org/apache/el/stream/TestCollectionOperations.java +++ b/test/org/apache/el/stream/TestCollectionOperations.java @@ -222,9 +222,9 @@ public class TestCollectionOperations { "[3, 1, 2].stream().sorted((x,y)->null).toList()", List.class); List<Long> expected = new ArrayList<>(3); - expected.add(3L); - expected.add(1L); - expected.add(2L); + expected.add(Long.valueOf(3)); + expected.add(Long.valueOf(1)); + expected.add(Long.valueOf(2)); Assert.assertEquals(expected, result); } @@ -334,11 +334,11 @@ public class TestCollectionOperations { Object.class); List<Long> expected = new ArrayList<>(5); - expected.add(1L); - expected.add(2L); - expected.add(3L); - expected.add(4L); - expected.add(5L); + expected.add(Long.valueOf(1)); + expected.add(Long.valueOf(2)); + expected.add(Long.valueOf(3)); + expected.add(Long.valueOf(4)); + expected.add(Long.valueOf(5)); Assert.assertEquals(expected, result); } @@ -355,11 +355,11 @@ public class TestCollectionOperations { Object.class); List<Long> expected = new ArrayList<>(5); - expected.add(1L); - expected.add(2L); - expected.add(3L); - expected.add(4L); - expected.add(5L); + expected.add(Long.valueOf(1)); + expected.add(Long.valueOf(2)); + expected.add(Long.valueOf(3)); + expected.add(Long.valueOf(4)); + expected.add(Long.valueOf(5)); Assert.assertEquals(expected, result); } @@ -376,8 +376,8 @@ public class TestCollectionOperations { Object.class); List<Long> expected = new ArrayList<>(2); - expected.add(1L); - expected.add(2L); + expected.add(Long.valueOf(1)); + expected.add(Long.valueOf(2)); Assert.assertEquals(expected, result); } @@ -393,7 +393,7 @@ public class TestCollectionOperations { "[1].stream().substream(2,3).toList()", Object.class); - Assert.assertEquals(new ArrayList<Long>(), result); + Assert.assertEquals(new ArrayList<>(), result); } @@ -535,7 +535,7 @@ public class TestCollectionOperations { "[1, 2, 3].stream().max((x,y)->null)", Object.class); - Assert.assertEquals(1L, ((Optional) result).get()); + Assert.assertEquals(Long.valueOf(1), ((Optional) result).get()); } @@ -621,7 +621,7 @@ public class TestCollectionOperations { "[1, 2, 3].stream().min((x,y)->null)", Object.class); - Assert.assertEquals(1L, ((Optional) result).get()); + Assert.assertEquals(Long.valueOf(1), ((Optional) result).get()); } diff --git a/test/org/apache/jasper/compiler/TestJavaCompiler.java b/test/org/apache/jasper/compiler/TestJavaCompiler.java index 452a37322d..f4f3c090b9 100644 --- a/test/org/apache/jasper/compiler/TestJavaCompiler.java +++ b/test/org/apache/jasper/compiler/TestJavaCompiler.java @@ -89,7 +89,7 @@ public class TestJavaCompiler { .andReturn(javaFile.getAbsolutePath()).anyTimes(); EasyMock.expect(ctxt.getClassPath()) .andReturn(System.getProperty("java.class.path")).anyTimes(); - EasyMock.expect(ctxt.keepGenerated()).andReturn(false).anyTimes(); + EasyMock.expect(Boolean.valueOf(ctxt.keepGenerated())).andReturn(Boolean.FALSE).anyTimes(); EasyMock.replay(ctxt); JavaCompiler compiler = new JavaCompiler(); diff --git a/test/org/apache/jasper/util/TestFastRemovalDequeue.java b/test/org/apache/jasper/util/TestFastRemovalDequeue.java index 5834dbf2da..cbe9e0c7df 100644 --- a/test/org/apache/jasper/util/TestFastRemovalDequeue.java +++ b/test/org/apache/jasper/util/TestFastRemovalDequeue.java @@ -197,9 +197,8 @@ public class TestFastRemovalDequeue { /* - * A maximum size of one must be honoured. The constructor used to - * silently raise it to two, so a configured maxLoadedJsps of one kept - * two JSPs loaded and evicted nothing until a third one was requested. + * A maximum size of one must be honoured. The constructor used to silently raise it to two, so a configured + * maxLoadedJsps of one kept two JSPs loaded and evicted nothing until a third one was requested. */ @Test public void testSingleSizeIsHonoured() throws Exception { @@ -242,9 +241,8 @@ public class TestFastRemovalDequeue { /* - * The rendering of an entry must tolerate null content, as the JDK - * collections render null elements, rather than fail with a null pointer - * exception. + * The rendering of an entry must tolerate null content, as the JDK collections render null elements, rather than + * fail with a null pointer exception. */ @Test public void testNullContentToString() throws Exception { @@ -257,20 +255,22 @@ public class TestFastRemovalDequeue { /* - * A maximum size below one cannot produce a usable queue and is - * rejected, rather than silently replaced by a different size. + * A maximum size below one cannot produce a usable queue and is rejected, rather than silently replaced by a + * different size. */ @Test public void testInvalidMaxSize() throws Exception { try { - new FastRemovalDequeue<Object>(0); + @SuppressWarnings("unused") + FastRemovalDequeue<Object> dqueue = new FastRemovalDequeue<>(0); Assert.fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { // The message is localized, pin the rendered value Assert.assertTrue(e.getMessage(), e.getMessage().contains("[0]")); } try { - new FastRemovalDequeue<Object>(-1); + @SuppressWarnings("unused") + FastRemovalDequeue<Object> dqueue = new FastRemovalDequeue<>(-1); Assert.fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { Assert.assertTrue(e.getMessage(), e.getMessage().contains("[-1]")); diff --git a/test/org/apache/tomcat/util/TestIntrospectionUtils.java b/test/org/apache/tomcat/util/TestIntrospectionUtils.java index e1410f54b0..ac0ddc9484 100644 --- a/test/org/apache/tomcat/util/TestIntrospectionUtils.java +++ b/test/org/apache/tomcat/util/TestIntrospectionUtils.java @@ -193,6 +193,7 @@ public class TestIntrospectionUtils { return unsupported; } + @SuppressWarnings("unused") public void setProperty(String name, String value) { genericCalled = true; } diff --git a/test/org/apache/tomcat/util/collections/TestCaseInsensitiveKeyMap.java b/test/org/apache/tomcat/util/collections/TestCaseInsensitiveKeyMap.java index 44be5891da..c61d29ca4d 100644 --- a/test/org/apache/tomcat/util/collections/TestCaseInsensitiveKeyMap.java +++ b/test/org/apache/tomcat/util/collections/TestCaseInsensitiveKeyMap.java @@ -221,6 +221,7 @@ public class TestCaseInsensitiveKeyMap { } + @SuppressWarnings("unlikely-arg-type") @Test public void testKeySetContainsAndRemoveInvalidKeys() { CaseInsensitiveKeyMap<Object> map = new CaseInsensitiveKeyMap<>(); diff --git a/test/org/apache/tomcat/util/collections/TestSynchronizedQueue.java b/test/org/apache/tomcat/util/collections/TestSynchronizedQueue.java index c140343397..5235e22768 100644 --- a/test/org/apache/tomcat/util/collections/TestSynchronizedQueue.java +++ b/test/org/apache/tomcat/util/collections/TestSynchronizedQueue.java @@ -118,12 +118,14 @@ public class TestSynchronizedQueue { @Test(expected = IllegalArgumentException.class) public void testZeroInitialSizeRejected() { - new SynchronizedQueue<>(0); + @SuppressWarnings("unused") + SynchronizedQueue<Object> queue = new SynchronizedQueue<>(0); } @Test(expected = IllegalArgumentException.class) public void testNegativeInitialSizeRejected() { - new SynchronizedQueue<>(-1); + @SuppressWarnings("unused") + SynchronizedQueue<Object> queue = new SynchronizedQueue<>(-1); } @Test diff --git a/test/org/apache/tomcat/util/descriptor/tld/TestTldResourcePath.java b/test/org/apache/tomcat/util/descriptor/tld/TestTldResourcePath.java index d614b9452a..cc9705ca40 100644 --- a/test/org/apache/tomcat/util/descriptor/tld/TestTldResourcePath.java +++ b/test/org/apache/tomcat/util/descriptor/tld/TestTldResourcePath.java @@ -28,18 +28,21 @@ public class TestTldResourcePath { @Test(expected = IllegalArgumentException.class) public void testNullUrlRejectedTwoArg() { - new TldResourcePath(null, "/WEB-INF/tld/test.tld"); + @SuppressWarnings("unused") + TldResourcePath path = new TldResourcePath(null, "/WEB-INF/tld/test.tld"); } @Test(expected = IllegalArgumentException.class) public void testNullUrlRejectedThreeArg() { - new TldResourcePath(null, "/WEB-INF/lib/test.jar", "META-INF/test.tld"); + @SuppressWarnings("unused") + TldResourcePath path = new TldResourcePath(null, "/WEB-INF/lib/test.jar", "META-INF/test.tld"); } @Test public void testNullUrlMessage() { try { - new TldResourcePath(null, "/WEB-INF/tld/test.tld"); + @SuppressWarnings("unused") + TldResourcePath path = new TldResourcePath(null, "/WEB-INF/tld/test.tld"); Assert.fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = StringManager.getManager(TldResourcePath.class) diff --git a/test/org/apache/tomcat/util/modeler/TestBaseModelMBeanNotifications.java b/test/org/apache/tomcat/util/modeler/TestBaseModelMBeanNotifications.java index 031078b713..c7ab30fe6f 100644 --- a/test/org/apache/tomcat/util/modeler/TestBaseModelMBeanNotifications.java +++ b/test/org/apache/tomcat/util/modeler/TestBaseModelMBeanNotifications.java @@ -38,7 +38,7 @@ public class TestBaseModelMBeanNotifications { @Override public void handleNotification(Notification notification, Object handback) { - sequences.add(notification.getSequenceNumber()); + sequences.add(Long.valueOf(notification.getSequenceNumber())); String name; if (notification instanceof AttributeChangeNotification) { AttributeChangeNotification acn = (AttributeChangeNotification) notification; diff --git a/test/org/apache/tomcat/util/net/jsse/TestPEMFile.java b/test/org/apache/tomcat/util/net/jsse/TestPEMFile.java index 92afbf89d0..9a420b2e45 100644 --- a/test/org/apache/tomcat/util/net/jsse/TestPEMFile.java +++ b/test/org/apache/tomcat/util/net/jsse/TestPEMFile.java @@ -46,17 +46,19 @@ public class TestPEMFile { private static final String KEY_ENCRYPTED_PKCS1_AES128 = "key-encrypted-pkcs1-aes128.pem"; private static final String KEY_ENCRYPTED_PKCS1_AES192 = "key-encrypted-pkcs1-aes192.pem"; private static final String KEY_ENCRYPTED_PKCS1_AES256 = "key-encrypted-pkcs1-aes256.pem"; - private static final String KEY_ENCRYPTED_PKCS8_HMACSHA1DEFAULT_DES_EDE3_CBC = "key-encrypted-pkcs8-hmacsha1default-des-ede3-cbc.pem"; - private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_AES_128_CBC = "key-encrypted-pkcs8-hmacsha256-aes-128-cbc.pem"; - private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_AES_256_CBC = "key-encrypted-pkcs8-hmacsha256-aes-256-cbc.pem"; - private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_DES_EDE3_CBC = "key-encrypted-pkcs8-hmacsha256-des-ede3-cbc.pem"; + private static final String KEY_ENCRYPTED_PKCS8_HMACSHA1DEFAULT_DES_EDE3_CBC = + "key-encrypted-pkcs8-hmacsha1default-des-ede3-cbc.pem"; + private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_AES_128_CBC = + "key-encrypted-pkcs8-hmacsha256-aes-128-cbc.pem"; + private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_AES_256_CBC = + "key-encrypted-pkcs8-hmacsha256-aes-256-cbc.pem"; + private static final String KEY_ENCRYPTED_PKCS8_HMACSHA256_DES_EDE3_CBC = + "key-encrypted-pkcs8-hmacsha256-des-ede3-cbc.pem"; /* - * A clean single certificate PEM. Generated with: - * keytool -exportcert -rfc -keystore test/localhost-rsa.jks - * -storepass changeit -alias tomcat - * with the line endings converted from CRLF to LF. The certificate itself - * expires on 2028-08-11. + * A clean single certificate PEM. Generated with: keytool -exportcert -rfc -keystore test/localhost-rsa.jks + * -storepass changeit -alias tomcat with the line endings converted from CRLF to LF. The certificate itself expires + * on 2028-08-11. */ private static final String CERTIFICATE = "certificate.pem"; @@ -128,12 +130,13 @@ public class TestPEMFile { // the failure of an attempt to use the name as a transformation. The // algorithm is rejected before the content is decrypted, so the rest // of the content does not matter. - String pem = "-----BEGIN RSA PRIVATE KEY-----\n" + "Proc-Type: 4,ENCRYPTED\n" - + "DEK-Info: AES-128-CTR,0123456789ABCDEF0123456789ABCDEF\n" + "QUJDRA==\n" - + "-----END RSA PRIVATE KEY-----\n"; + String pem = "-----BEGIN RSA PRIVATE KEY-----\n" + "Proc-Type: 4,ENCRYPTED\n" + + "DEK-Info: AES-128-CTR,0123456789ABCDEF0123456789ABCDEF\n" + "QUJDRA==\n" + + "-----END RSA PRIVATE KEY-----\n"; try { - new PEMFile("unsupported", new ByteArrayInputStream(pem.getBytes(StandardCharsets.US_ASCII)), KEY_PASSWORD, - null); + @SuppressWarnings("unused") + PEMFile pf = new PEMFile("unsupported", new ByteArrayInputStream(pem.getBytes(StandardCharsets.US_ASCII)), + KEY_PASSWORD, null); Assert.fail("Expected the unsupported encryption algorithm to be rejected"); } catch (NoSuchAlgorithmException nsae) { // Expected @@ -234,8 +237,8 @@ public class TestPEMFile { @Test public void testDekInfoWithoutAlgorithmAndIv() throws Exception { - assertInvalidPem("-----BEGIN RSA PRIVATE KEY-----\n" + "DEK-Info: DES-EDE3-CBC\n" + "QUJD\n" - + "-----END RSA PRIVATE KEY-----\n"); + assertInvalidPem("-----BEGIN RSA PRIVATE KEY-----\n" + "DEK-Info: DES-EDE3-CBC\n" + "QUJD\n" + + "-----END RSA PRIVATE KEY-----\n"); } @@ -254,14 +257,14 @@ public class TestPEMFile { /* - * The structure of the file is checked while it is scanned, before any of - * the content is decoded, so these malformed structures must be rejected - * even though the content is not valid PEM encoded data. + * The structure of the file is checked while it is scanned, before any of the content is decoded, so these + * malformed structures must be rejected even though the content is not valid PEM encoded data. */ private void assertInvalidPem(String content) throws Exception { ByteArrayInputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.US_ASCII)); try { - new PEMFile("invalid", stream, null, null); + @SuppressWarnings("unused") + PEMFile pf = new PEMFile("invalid", stream, null, null); Assert.fail("Expected the malformed PEM to be rejected"); } catch (IOException ioe) { // Expected diff --git a/test/org/apache/tomcat/util/scan/TestJarFileUrlJar.java b/test/org/apache/tomcat/util/scan/TestJarFileUrlJar.java index eacef7ee04..9165d5e70c 100644 --- a/test/org/apache/tomcat/util/scan/TestJarFileUrlJar.java +++ b/test/org/apache/tomcat/util/scan/TestJarFileUrlJar.java @@ -74,7 +74,7 @@ public class TestJarFileUrlJar { } } - private static List<String> entryNames(Jar jar) throws IOException { + private static List<String> entryNames(Jar jar) { List<String> names = new ArrayList<>(); jar.nextEntry(); while (jar.getEntryName() != null) { diff --git a/test/org/apache/tomcat/util/scan/TestJarFileUrlNestedJar.java b/test/org/apache/tomcat/util/scan/TestJarFileUrlNestedJar.java index 0eceb7614a..1ef26d247a 100644 --- a/test/org/apache/tomcat/util/scan/TestJarFileUrlNestedJar.java +++ b/test/org/apache/tomcat/util/scan/TestJarFileUrlNestedJar.java @@ -22,7 +22,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URL; +import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.jar.Attributes; import java.util.jar.JarEntry; @@ -99,7 +99,8 @@ public class TestJarFileUrlNestedJar { String nestedPath = "WEB-INF/lib/nested.jar"; File war = createWar(nestedPath); - try (Jar jar = new JarFileUrlNestedJar(new URL("jar:file:" + war.getAbsolutePath() + "!/" + nestedPath))) { + try (Jar jar = + new JarFileUrlNestedJar(new URI("jar:file:" + war.getAbsolutePath() + "!/" + nestedPath).toURL())) { Assert.assertTrue(jar.exists(TEST_ENTRY)); Assert.assertArrayEquals(TEST_CONTENT, readJar(jar)); } @@ -107,15 +108,15 @@ public class TestJarFileUrlNestedJar { /* - * A percent-encoded entry name must resolve to the same entry that the JDK resolves it to, rather than - * resulting in a JAR with no usable content. + * A percent-encoded entry name must resolve to the same entry that the JDK resolves it to, rather than resulting in + * a JAR with no usable content. */ @Test public void testEncodedEntryName() throws Exception { File war = createWar("WEB-INF/lib/my jar.jar"); try (Jar jar = new JarFileUrlNestedJar( - new URL("jar:file:" + war.getAbsolutePath() + "!/WEB-INF/lib/my%20jar.jar"))) { + new URI("jar:file:" + war.getAbsolutePath() + "!/WEB-INF/lib/my%20jar.jar").toURL())) { Assert.assertTrue(jar.exists(TEST_ENTRY)); Assert.assertArrayEquals(TEST_CONTENT, readJar(jar)); } @@ -123,42 +124,42 @@ public class TestJarFileUrlNestedJar { /* - * A URL that does not refer to an existing entry must fail when the JAR is constructed rather than later when - * the content is accessed. + * A URL that does not refer to an existing entry must fail when the JAR is constructed rather than later when the + * content is accessed. */ @Test public void testMissingEntryThrows() throws Exception { File war = createWar("WEB-INF/lib/nested.jar"); Assert.assertThrows(IOException.class, () -> new JarFileUrlNestedJar( - new URL("jar:file:" + war.getAbsolutePath() + "!/WEB-INF/lib/missing.jar"))); + new URI("jar:file:" + war.getAbsolutePath() + "!/WEB-INF/lib/missing.jar").toURL())); } /* - * A URL that does not name an entry (it refers to the whole archive) must fail when the JAR is constructed - * rather than later when the content is accessed. JarFactory routes such URLs elsewhere. This covers direct - * construction of JarFileUrlNestedJar with such a URL. + * A URL that does not name an entry (it refers to the whole archive) must fail when the JAR is constructed rather + * than later when the content is accessed. JarFactory routes such URLs elsewhere. This covers direct construction + * of JarFileUrlNestedJar with such a URL. */ @Test public void testEmptyEntryNameThrows() throws Exception { File war = createWar("WEB-INF/lib/nested.jar"); Assert.assertThrows(FileNotFoundException.class, - () -> new JarFileUrlNestedJar(new URL("jar:file:" + war.getAbsolutePath() + "!/"))); + () -> new JarFileUrlNestedJar(new URI("jar:file:" + war.getAbsolutePath() + "!/").toURL())); } /* - * A URL that does not contain the JAR entry separator must fail with an IOException before the JAR can be used. - * In practice the JDK's jar URL handler rejects such a spec ("no !/ in spec") with a MalformedURLException when - * the URL is created, so a URL of this form never reaches JarFileUrlNestedJar via JarFactory. + * A URL that does not contain the JAR entry separator must fail with an IOException before the JAR can be used. In + * practice the JDK's jar URL handler rejects such a spec ("no !/ in spec") with a MalformedURLException when the + * URL is created, so a URL of this form never reaches JarFileUrlNestedJar via JarFactory. */ @Test public void testMissingSeparatorThrows() throws Exception { File war = createWar("WEB-INF/lib/nested.jar"); Assert.assertThrows(IOException.class, - () -> new JarFileUrlNestedJar(new URL("jar:file:" + war.getAbsolutePath() + "!x"))); + () -> new JarFileUrlNestedJar(new URI("jar:file:" + war.getAbsolutePath() + "!x").toURL())); } } diff --git a/test/org/apache/tomcat/util/threads/TestInlineExecutorService.java b/test/org/apache/tomcat/util/threads/TestInlineExecutorService.java index a1b3b5c7a0..adb2741c5a 100644 --- a/test/org/apache/tomcat/util/threads/TestInlineExecutorService.java +++ b/test/org/apache/tomcat/util/threads/TestInlineExecutorService.java @@ -32,54 +32,57 @@ public class TestInlineExecutorService { @Test public void testTerminationWaitsForAllRunningTasks() throws Exception { InlineExecutorService executor = new InlineExecutorService(); - - CountDownLatch tasksStarted = new CountDownLatch(2); - CountDownLatch firstTaskDone = new CountDownLatch(1); - CountDownLatch releaseSecondTask = new CountDownLatch(1); - CountDownLatch secondTaskDone = new CountDownLatch(1); - - Runnable firstTask = () -> { - tasksStarted.countDown(); - try { - Thread.sleep(300); - } catch (InterruptedException e) { - // Ignore - } - firstTaskDone.countDown(); - }; - Runnable secondTask = () -> { - tasksStarted.countDown(); - try { - releaseSecondTask.await(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - // Ignore - } - secondTaskDone.countDown(); - }; - - Thread firstThread = new Thread(() -> executor.execute(firstTask)); - Thread secondThread = new Thread(() -> executor.execute(secondTask)); - - firstThread.start(); - secondThread.start(); - - Assert.assertTrue("Tasks did not start", tasksStarted.await(10, TimeUnit.SECONDS)); - Assert.assertTrue("First task did not complete", firstTaskDone.await(10, TimeUnit.SECONDS)); - - // The second task is still running at this point - executor.shutdown(); - Assert.assertFalse("Terminated while a task was still running", executor.isTerminated()); - Assert.assertFalse("awaitTermination returned true while a task was still running", - executor.awaitTermination(100, TimeUnit.MILLISECONDS)); - - releaseSecondTask.countDown(); - firstThread.join(TimeUnit.SECONDS.toMillis(10)); - secondThread.join(TimeUnit.SECONDS.toMillis(10)); - Assert.assertFalse("Second thread did not complete", secondThread.isAlive()); - - Assert.assertTrue("Not terminated after all tasks completed", executor.isTerminated()); - Assert.assertTrue("awaitTermination returned false after termination", - executor.awaitTermination(10, TimeUnit.SECONDS)); + try { + CountDownLatch tasksStarted = new CountDownLatch(2); + CountDownLatch firstTaskDone = new CountDownLatch(1); + CountDownLatch releaseSecondTask = new CountDownLatch(1); + CountDownLatch secondTaskDone = new CountDownLatch(1); + + Runnable firstTask = () -> { + tasksStarted.countDown(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + // Ignore + } + firstTaskDone.countDown(); + }; + Runnable secondTask = () -> { + tasksStarted.countDown(); + try { + releaseSecondTask.await(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + // Ignore + } + secondTaskDone.countDown(); + }; + + Thread firstThread = new Thread(() -> executor.execute(firstTask)); + Thread secondThread = new Thread(() -> executor.execute(secondTask)); + + firstThread.start(); + secondThread.start(); + + Assert.assertTrue("Tasks did not start", tasksStarted.await(10, TimeUnit.SECONDS)); + Assert.assertTrue("First task did not complete", firstTaskDone.await(10, TimeUnit.SECONDS)); + + // The second task is still running at this point + executor.shutdown(); + Assert.assertFalse("Terminated while a task was still running", executor.isTerminated()); + Assert.assertFalse("awaitTermination returned true while a task was still running", + executor.awaitTermination(100, TimeUnit.MILLISECONDS)); + + releaseSecondTask.countDown(); + firstThread.join(TimeUnit.SECONDS.toMillis(10)); + secondThread.join(TimeUnit.SECONDS.toMillis(10)); + Assert.assertFalse("Second thread did not complete", secondThread.isAlive()); + + Assert.assertTrue("Not terminated after all tasks completed", executor.isTerminated()); + Assert.assertTrue("awaitTermination returned false after termination", + executor.awaitTermination(10, TimeUnit.SECONDS)); + } finally { + executor.shutdownNow(); + } } @@ -90,13 +93,16 @@ public class TestInlineExecutorService { @Test public void testReentrantExecute() throws Exception { InlineExecutorService executor = new InlineExecutorService(); - - executor.execute(() -> executor.execute(() -> { - // Inner task. Does nothing. - })); - - executor.shutdown(); - Assert.assertTrue("Not terminated after nested tasks completed", executor.isTerminated()); + try { + executor.execute(() -> executor.execute(() -> { + // Inner task. Does nothing. + })); + + executor.shutdown(); + Assert.assertTrue("Not terminated after nested tasks completed", executor.isTerminated()); + } finally { + executor.shutdownNow(); + } } @@ -107,27 +113,30 @@ public class TestInlineExecutorService { @Test public void testAwaitTerminationWakesOnShutdown() throws Exception { InlineExecutorService executor = new InlineExecutorService(); - - CountDownLatch waiterReturned = new CountDownLatch(1); - Boolean[] result = new Boolean[1]; - Thread waiter = new Thread(() -> { - try { - result[0] = executor.awaitTermination(60, TimeUnit.SECONDS); - } catch (InterruptedException e) { - // Ignore - } - waiterReturned.countDown(); - }); - waiter.start(); - - // Give the waiter thread time to start waiting - Thread.sleep(100); - - executor.shutdown(); - - Assert.assertTrue("Waiting thread was not woken", waiterReturned.await(10, TimeUnit.SECONDS)); - Assert.assertEquals(Boolean.TRUE, result[0]); - waiter.join(TimeUnit.SECONDS.toMillis(10)); + try { + CountDownLatch waiterReturned = new CountDownLatch(1); + Boolean[] result = new Boolean[1]; + Thread waiter = new Thread(() -> { + try { + result[0] = Boolean.valueOf(executor.awaitTermination(60, TimeUnit.SECONDS)); + } catch (InterruptedException e) { + // Ignore + } + waiterReturned.countDown(); + }); + waiter.start(); + + // Give the waiter thread time to start waiting + Thread.sleep(100); + + executor.shutdown(); + + Assert.assertTrue("Waiting thread was not woken", waiterReturned.await(10, TimeUnit.SECONDS)); + Assert.assertEquals(Boolean.TRUE, result[0]); + waiter.join(TimeUnit.SECONDS.toMillis(10)); + } finally { + executor.shutdownNow(); + } } @@ -137,7 +146,6 @@ public class TestInlineExecutorService { @Test public void testRejectAfterShutdown() throws Exception { InlineExecutorService executor = new InlineExecutorService(); - executor.shutdown(); Assert.assertThrows(RejectedExecutionException.class, () -> executor.execute(() -> { diff --git a/test/org/apache/tomcat/util/threads/TestTaskQueue.java b/test/org/apache/tomcat/util/threads/TestTaskQueue.java index 6d117b9cce..5c39ddf0dc 100644 --- a/test/org/apache/tomcat/util/threads/TestTaskQueue.java +++ b/test/org/apache/tomcat/util/threads/TestTaskQueue.java @@ -27,6 +27,8 @@ public class TestTaskQueue { private static class CountingTaskQueue extends TaskQueue { + private static final long serialVersionUID = 1L; + private final AtomicInteger pollCount = new AtomicInteger(); @Override diff --git a/test/org/apache/tomcat/util/threads/TestThreadPoolExecutor.java b/test/org/apache/tomcat/util/threads/TestThreadPoolExecutor.java index 0c299bf6fb..913ba79824 100644 --- a/test/org/apache/tomcat/util/threads/TestThreadPoolExecutor.java +++ b/test/org/apache/tomcat/util/threads/TestThreadPoolExecutor.java @@ -29,9 +29,9 @@ import org.junit.Test; public class TestThreadPoolExecutor { /* - * The submitted task count is used by TaskQueue.offer() to decide if a task should be queued or a new thread - * should be created. A task that is counted when submitted but never reaches afterExecute() leaves the count - * permanently inflated. + * The submitted task count is used by TaskQueue.offer() to decide if a task should be queued or a new thread should + * be created. A task that is counted when submitted but never reaches afterExecute() leaves the count permanently + * inflated. */ private static ThreadPoolExecutor createPool(ThreadPoolExecutor.RejectedExecutionHandler handler) { @@ -89,9 +89,8 @@ public class TestThreadPoolExecutor { @Test public void testNonThrowingRejectionHandlerKeepsSubmittedCount() throws Exception { // Test both handlers that do not throw. - for (ThreadPoolExecutor.RejectedExecutionHandler handler : - new ThreadPoolExecutor.RejectedExecutionHandler[] { new ThreadPoolExecutor.DiscardPolicy(), - new ThreadPoolExecutor.CallerRunsPolicy() }) { + for (ThreadPoolExecutor.RejectedExecutionHandler handler : new ThreadPoolExecutor.RejectedExecutionHandler[] { + new ThreadPoolExecutor.DiscardPolicy(), new ThreadPoolExecutor.CallerRunsPolicy() }) { CountDownLatch release = new CountDownLatch(1); boolean expectRunInCaller = handler instanceof ThreadPoolExecutor.CallerRunsPolicy; ThreadPoolExecutor pool = createPool(handler); @@ -104,7 +103,8 @@ public class TestThreadPoolExecutor { pool.execute(() -> ran.set(true)); // rejected: discarded or run by this thread // Only the running and the queued task are still outstanding. Assert.assertEquals(handler.getClass().getName(), 2, pool.getSubmittedCount()); - Assert.assertEquals(handler.getClass().getName(), expectRunInCaller, ran.get()); + Assert.assertEquals(handler.getClass().getName(), Boolean.valueOf(expectRunInCaller), + Boolean.valueOf(ran.get())); release.countDown(); awaitSubmittedCount(pool, 0); } finally { @@ -182,8 +182,8 @@ public class TestThreadPoolExecutor { } /* - * If beforeExecute() throws, the worker dies without processing the task and without calling afterExecute(), so - * the submitted count must be decremented for the lost task. + * If beforeExecute() throws, the worker dies without processing the task and without calling afterExecute(), so the + * submitted count must be decremented for the lost task. */ @Test public void testBeforeExecuteThrowKeepsSubmittedCount() throws Exception { diff --git a/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java b/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java index b164836f50..903d6741f6 100644 --- a/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java +++ b/test/org/apache/tomcat/websocket/pojo/TestPojoMethodMapping.java @@ -105,7 +105,9 @@ public class TestPojoMethodMapping extends TomcatBaseTest { @Test public void testPrimitiveAndBooleanParameters() throws Exception { try { - new PojoMethodMapping(PrimitiveAndBooleanServer.class, new ArrayList<>(), "/primitiveAndBoolean", null); + @SuppressWarnings("unused") + PojoMethodMapping mapping = new PojoMethodMapping(PrimitiveAndBooleanServer.class, new ArrayList<>(), + "/primitiveAndBoolean", null); Assert.fail("Expected a DeploymentException"); } catch (DeploymentException de) { Assert.assertTrue("Unexpected message: " + de.getMessage(), de.getMessage().contains("primitive type")); @@ -124,22 +126,22 @@ public class TestPojoMethodMapping extends TomcatBaseTest { /* - * A sub-class method that overrides an annotated super class method using a covariant return - * type is still an override. Re-declaring the annotation on the override must not be treated - * as a duplicate annotation and the sub-class method must be the one that is mapped. + * A sub-class method that overrides an annotated super class method using a covariant return type is still an + * override. Re-declaring the annotation on the override must not be treated as a duplicate annotation and the + * sub-class method must be the one that is mapped. */ @Test public void testCovariantReturnOverride() throws Exception { - PojoMethodMapping mapping = new PojoMethodMapping(CovariantReturnServer.class, new ArrayList<>(), - "/covariantReturn", null); + PojoMethodMapping mapping = + new PojoMethodMapping(CovariantReturnServer.class, new ArrayList<>(), "/covariantReturn", null); Assert.assertEquals(CovariantReturnServer.class.getMethod("onOpen", Session.class), mapping.getOnOpen()); } /* - * A non-annotated sub-class method that overrides an annotated super class method using a - * covariant return type should result in the super class method being ignored. Note that a - * compiler generated bridge method previously masked this in compiled code. + * A non-annotated sub-class method that overrides an annotated super class method using a covariant return type + * should result in the super class method being ignored. Note that a compiler generated bridge method previously + * masked this in compiled code. */ @Test public void testCovariantReturnOverrideWithoutAnnotation() throws Exception { @@ -150,13 +152,15 @@ public class TestPojoMethodMapping extends TomcatBaseTest { /* - * A sub-class method that is not an override of the annotated super class method must still - * be rejected as a duplicate annotation if it handles the same message type. + * A sub-class method that is not an override of the annotated super class method must still be rejected as a + * duplicate annotation if it handles the same message type. */ @Test public void testAnnotatedMethodNotAnOverride() throws Exception { try { - new PojoMethodMapping(NotAnOverrideServer.class, new ArrayList<>(), "/notAnOverride", null); + @SuppressWarnings("unused") + PojoMethodMapping mapping = + new PojoMethodMapping(NotAnOverrideServer.class, new ArrayList<>(), "/notAnOverride", null); Assert.fail("Expected a DeploymentException"); } catch (DeploymentException de) { Assert.assertTrue("Unexpected message: " + de.getMessage(), diff --git a/test/org/apache/tomcat/websocket/server/TestWsServerContainer.java b/test/org/apache/tomcat/websocket/server/TestWsServerContainer.java index 3c77c07ad3..f88a16d1c0 100644 --- a/test/org/apache/tomcat/websocket/server/TestWsServerContainer.java +++ b/test/org/apache/tomcat/websocket/server/TestWsServerContainer.java @@ -486,8 +486,7 @@ public class TestWsServerContainer extends WebSocketBaseTest { public static class NoMethodsEndpoint extends Endpoint { @Override - public void onOpen(@SuppressWarnings("unused") Session session, - @SuppressWarnings("unused") EndpointConfig config) { + public void onOpen(Session session, EndpointConfig config) { // NO-OP } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
