This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new a7204e0e77b [improve][test] Fix try-with-resources compile warnings in
test code (#25429)
a7204e0e77b is described below
commit a7204e0e77b81167362c88bceb58dc3de7970708
Author: Matteo Merli <[email protected]>
AuthorDate: Mon Mar 30 21:07:58 2026 -0700
[improve][test] Fix try-with-resources compile warnings in test code
(#25429)
---
.../java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java | 2 ++
.../java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java | 1 +
.../org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java | 2 ++
.../src/test/java/org/apache/pulsar/broker/auth/PortForwarder.java | 2 ++
.../org/apache/pulsar/broker/testcontext/PulsarTestContext.java | 2 ++
.../transaction/coordinator/TransactionMetaStoreAssignmentTest.java | 2 +-
.../test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java | 1 +
.../apache/pulsar/client/impl/tracing/OpenTelemetryTracingTest.java | 3 ++-
.../pulsar/common/allocator/PulsarByteBufAllocatorDefaultTest.java | 1 +
.../allocator/PulsarByteBufAllocatorOomThrowExceptionTest.java | 1 +
.../org/apache/pulsar/common/util/FileModifiedTimeUpdaterTest.java | 1 +
.../java/org/apache/pulsar/common/util/netty/SslContextTest.java | 4 ++++
.../pulsar/functions/source/batch/BatchSourceExecutorTest.java | 3 +++
.../java/org/apache/pulsar/functions/utils/SinkConfigUtilsTest.java | 1 +
.../apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java | 4 ++--
.../test/java/org/apache/pulsar/io/core/BatchPushSourceTest.java | 1 +
.../src/test/java/org/apache/pulsar/io/core/PushSourceTest.java | 1 +
.../core/src/test/java/org/apache/pulsar/io/core/SinkTest.java | 1 +
.../core/src/test/java/org/apache/pulsar/io/core/SourceTest.java | 1 +
.../bookkeeper/replication/AuditorPeriodicBookieCheckTest.java | 3 ++-
.../org/apache/bookkeeper/replication/AuditorReplicasCheckTest.java | 1 +
.../org/apache/bookkeeper/replication/TestReplicationWorker.java | 6 +++---
.../src/test/java/org/apache/pulsar/metadata/TestZKServer.java | 1 +
.../apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java | 1 +
.../test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java | 1 +
.../src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java | 2 ++
.../offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java | 1 +
.../offload/jcloud/impl/BlockAwareSegmentInputStreamTest.java | 1 +
28 files changed, 43 insertions(+), 8 deletions(-)
diff --git
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
index 63519d10ba6..dcdd8eaaa88 100644
---
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
+++
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
@@ -6026,9 +6026,11 @@ public class ManagedCursorTest extends
MockedBookKeeperTestCase {
assertEquals(properties.get(propertyKey), lastIndex - 1);
}
+ @SuppressWarnings("try")
class TestPulsarMockBookKeeper extends PulsarMockBookKeeper {
Map<Long, Integer> ledgerErrors = new HashMap<>();
+ @SuppressWarnings("try")
public TestPulsarMockBookKeeper(OrderedExecutor orderedExecutor)
throws Exception {
super(orderedExecutor);
}
diff --git
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
index b1066c297c4..b1db138041b 100644
---
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
+++
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
@@ -3365,6 +3365,7 @@ public class ManagedLedgerTest extends
MockedBookKeeperTestCase {
* @throws Exception
*/
@Test(timeOut = 20000)
+ @SuppressWarnings("try")
public void testManagedLedgerWithAddEntryTimeOut() throws Exception {
ManagedLedgerConfig config = initManagedLedgerConfig(new
ManagedLedgerConfig()).setAddEntryTimeoutSeconds(1);
ManagedLedgerImpl ledger = (ManagedLedgerImpl)
factory.open("timeout_ledger_test", config);
diff --git
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
index 2c6bfba305b..e3bd102c299 100644
---
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
+++
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
@@ -365,6 +365,7 @@ public class OffloadPrefixReadTest extends
MockedBookKeeperTestCase {
private final AtomicInteger openedReadHandles = new AtomicInteger(0);
+ @SuppressWarnings("try")
class VerifyClosingReadHandle extends MockOffloadReadHandle {
VerifyClosingReadHandle(ReadHandle toCopy) throws Exception {
super(toCopy);
@@ -379,6 +380,7 @@ public class OffloadPrefixReadTest extends
MockedBookKeeperTestCase {
}
}
+ @SuppressWarnings("try")
static class MockOffloadReadHandle implements ReadHandle,
OffloadedLedgerHandle {
final long id;
final List<ByteBuf> entries = new ArrayList<>();
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/PortForwarder.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/PortForwarder.java
index 40b8f92c436..970410bcc0d 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/PortForwarder.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/PortForwarder.java
@@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
/**
* A TCP server that performs port forwarding for test purposes.
*/
+@SuppressWarnings("try")
public class PortForwarder implements AutoCloseable {
private static final Logger LOG =
LoggerFactory.getLogger(PortForwarder.class);
@@ -56,6 +57,7 @@ public class PortForwarder implements AutoCloseable {
* @param listenAddress the local address to listen on.
* @param targetAddress the remote address to forward traffic to.
*/
+ @SuppressWarnings("try")
public PortForwarder(SocketAddress listenAddress, SocketAddress
targetAddress) {
this.targetAddress = targetAddress;
this.bossGroup = new NioEventLoopGroup(1);
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java
index fce889882fe..17e64bd9fa0 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java
@@ -136,6 +136,7 @@ import org.mockito.internal.util.MockUtil;
@ToString
@Getter
@Builder(builderClassName = "Builder")
+@SuppressWarnings("try")
public class PulsarTestContext implements AutoCloseable {
private final ServiceConfiguration config;
private final MetadataStoreExtended localMetadataStore;
@@ -710,6 +711,7 @@ public class PulsarTestContext implements AutoCloseable {
CreateMode.PERSISTENT);
}
+ @SuppressWarnings("try")
private TestZKServer createTestZookeeper(int sessionTimeout) throws
Exception {
TestZKServer testZKServer = new TestZKServer();
try (ZooKeeper zkc = new
ZooKeeper(testZKServer.getConnectionString(), sessionTimeout, event -> {
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/coordinator/TransactionMetaStoreAssignmentTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/coordinator/TransactionMetaStoreAssignmentTest.java
index ba3e9e89d60..684cf68af98 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/coordinator/TransactionMetaStoreAssignmentTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/coordinator/TransactionMetaStoreAssignmentTest.java
@@ -108,7 +108,7 @@ public class TransactionMetaStoreAssignmentTest extends
TransactionTestBase {
});
}
- @SuppressWarnings("deprecation")
+ @SuppressWarnings({"try", "deprecation"})
private PulsarClient buildClient() throws Exception {
return PulsarClient.builder()
.serviceUrlProvider(new ServiceUrlProvider() {
diff --git
a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
index 2602adcd0a0..f39b4f3e21e 100644
---
a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
+++
b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
@@ -2710,6 +2710,7 @@ public class PulsarAdminToolTest {
}
}
+ @SuppressWarnings("try")
private static String runCustomCommand(String[] args) throws Exception {
File narFile = new File(PulsarAdminTool.class.getClassLoader()
.getResource("cliextensions/customCommands-nar.nar").getFile());
diff --git
a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryTracingTest.java
b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryTracingTest.java
index bbf92b9ffb1..23183ac5131 100644
---
a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryTracingTest.java
+++
b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryTracingTest.java
@@ -156,12 +156,13 @@ public class OpenTelemetryTracingTest {
}
@Test
+ @SuppressWarnings("try")
public void testContextPropagation() {
spanExporter.reset();
// Create a parent span
Span parentSpan = tracer.spanBuilder("parent").startSpan();
- try (Scope scope = parentSpan.makeCurrent()) {
+ try (Scope ignored = parentSpan.makeCurrent()) {
// Create a producer span as child
String topic = "test-topic";
Span producerSpan = TracingContext.createProducerSpan(tracer,
topic, Context.current());
diff --git
a/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorDefaultTest.java
b/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorDefaultTest.java
index f19f4a38ac2..0134ca258b7 100644
---
a/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorDefaultTest.java
+++
b/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorDefaultTest.java
@@ -37,6 +37,7 @@ import org.testng.annotations.Test;
public class PulsarByteBufAllocatorDefaultTest {
@Test
+ @SuppressWarnings("try")
public void testDefaultConfig() {
// Force initialize PulsarByteBufAllocator.DEFAULT before mock the
ctor so that it is not polluted.
assertNotNull(PulsarByteBufAllocator.DEFAULT);
diff --git
a/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorOomThrowExceptionTest.java
b/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorOomThrowExceptionTest.java
index 9bb9ea1eafe..f73d9348835 100644
---
a/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorOomThrowExceptionTest.java
+++
b/pulsar-common/src/test/java/org/apache/pulsar/common/allocator/PulsarByteBufAllocatorOomThrowExceptionTest.java
@@ -35,6 +35,7 @@ import org.testng.annotations.Test;
public class PulsarByteBufAllocatorOomThrowExceptionTest {
@Test
+ @SuppressWarnings("try")
public void testDefaultConfig() {
// Force initialize PulsarByteBufAllocator.DEFAULT before mock the
ctor so that it is not polluted.
assertNotNull(PulsarByteBufAllocator.DEFAULT);
diff --git
a/pulsar-common/src/test/java/org/apache/pulsar/common/util/FileModifiedTimeUpdaterTest.java
b/pulsar-common/src/test/java/org/apache/pulsar/common/util/FileModifiedTimeUpdaterTest.java
index c70110c775a..ad1f0d8bd7c 100644
---
a/pulsar-common/src/test/java/org/apache/pulsar/common/util/FileModifiedTimeUpdaterTest.java
+++
b/pulsar-common/src/test/java/org/apache/pulsar/common/util/FileModifiedTimeUpdaterTest.java
@@ -104,6 +104,7 @@ public class FileModifiedTimeUpdaterTest {
}
@Test
+ @SuppressWarnings("try")
public void testNettyClientSslContextRefresher() throws Exception {
BasicAuthenticationData provider = new BasicAuthenticationData(null);
String certFile = "/tmp/cert.txt";
diff --git
a/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
b/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
index 700be0985c2..8dc9b1de95a 100644
---
a/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
+++
b/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
@@ -81,6 +81,7 @@ public class SslContextTest {
}
@Test(dataProvider = "cipherDataProvider")
+ @SuppressWarnings("try")
public void testServerKeyStoreSSLContext(Set<String> cipher) throws
Exception {
PulsarSslConfiguration pulsarSslConfiguration =
PulsarSslConfiguration.builder()
.tlsEnabledWithKeystore(true)
@@ -108,6 +109,7 @@ public class SslContextTest {
}
@Test(dataProvider = "cipherDataProvider")
+ @SuppressWarnings("try")
public void testClientKeyStoreSSLContext(Set<String> cipher) throws
Exception {
PulsarSslConfiguration pulsarSslConfiguration =
PulsarSslConfiguration.builder()
.allowInsecureConnection(false)
@@ -125,6 +127,7 @@ public class SslContextTest {
}
@Test(dataProvider = "caCertSslContextDataProvider")
+ @SuppressWarnings("try")
public void testServerCaCertSslContextWithSslProvider(SslProvider
sslProvider, Set<String> ciphers)
throws Exception {
try (PulsarSslFactory pulsarSslFactory = new
DefaultPulsarSslFactory()) {
@@ -151,6 +154,7 @@ public class SslContextTest {
}
@Test(dataProvider = "caCertSslContextDataProvider")
+ @SuppressWarnings("try")
public void testClientCaCertSslContextWithSslProvider(SslProvider
sslProvider, Set<String> ciphers)
throws Exception {
try (PulsarSslFactory pulsarSslFactory = new
DefaultPulsarSslFactory()) {
diff --git
a/pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/source/batch/BatchSourceExecutorTest.java
b/pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/source/batch/BatchSourceExecutorTest.java
index 04106863a7a..9f6da056784 100644
---
a/pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/source/batch/BatchSourceExecutorTest.java
+++
b/pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/source/batch/BatchSourceExecutorTest.java
@@ -50,6 +50,7 @@ import org.testng.annotations.Test;
*/
public class BatchSourceExecutorTest {
+ @SuppressWarnings("try")
public static class TestBatchSource implements BatchSource<String> {
@Getter
public static int prepareCount;
@@ -96,6 +97,7 @@ public class BatchSourceExecutorTest {
}
}
+ @SuppressWarnings("try")
public static class TestBatchSourceFailDiscovery extends TestBatchSource {
@Override
public void discover(Consumer<byte[]> taskEater) throws Exception {
@@ -103,6 +105,7 @@ public class BatchSourceExecutorTest {
}
}
+ @SuppressWarnings("try")
public static class TestBatchPushSource extends BatchPushSource<String> {
@Getter
public static int prepareCount;
diff --git
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/SinkConfigUtilsTest.java
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/SinkConfigUtilsTest.java
index cde0b118214..a7eaaabb5a8 100644
---
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/SinkConfigUtilsTest.java
+++
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/SinkConfigUtilsTest.java
@@ -69,6 +69,7 @@ public class SinkConfigUtilsTest {
}
+ @SuppressWarnings("try")
public static class NopSink implements Sink<Object> {
@Override
diff --git
a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
index 21675bc2f65..a34d4e06914 100644
---
a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
+++
b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
@@ -896,7 +896,7 @@ public class FunctionRuntimeManagerTest {
}
}
- @SuppressWarnings("deprecation")
+ @SuppressWarnings({"deprecation", "try"})
@Test
public void testFunctionRuntimeFactoryConfigsBackwardsCompatibility()
throws Exception {
@@ -1082,7 +1082,7 @@ public class FunctionRuntimeManagerTest {
}
}
- @SuppressWarnings("deprecation")
+ @SuppressWarnings({"deprecation", "try"})
@Test
public void testKubernetesFunctionInstancesRestart() throws Exception {
diff --git
a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/BatchPushSourceTest.java
b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/BatchPushSourceTest.java
index a34da04b6fb..3770aafd545 100644
---
a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/BatchPushSourceTest.java
+++
b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/BatchPushSourceTest.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.testng.annotations.Test;
+@SuppressWarnings("try")
public class BatchPushSourceTest {
BatchPushSource testBatchSource = new BatchPushSource() {
diff --git
a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/PushSourceTest.java
b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/PushSourceTest.java
index 3c23e6401f0..7af65e20cca 100644
--- a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/PushSourceTest.java
+++ b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/PushSourceTest.java
@@ -21,6 +21,7 @@ package org.apache.pulsar.io.core;
import java.util.Map;
import org.testng.annotations.Test;
+@SuppressWarnings("try")
public class PushSourceTest {
PushSource testBatchSource = new PushSource() {
diff --git
a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SinkTest.java
b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SinkTest.java
index 87e4a53fa6c..51596f124ca 100644
--- a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SinkTest.java
+++ b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SinkTest.java
@@ -29,6 +29,7 @@ import org.testng.annotations.Test;
public class SinkTest {
+ @SuppressWarnings("try")
public static class TestSink implements Sink<String> {
@Override
diff --git
a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SourceTest.java
b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SourceTest.java
index e00369aa58a..5ce9be4aa93 100644
--- a/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SourceTest.java
+++ b/pulsar-io/core/src/test/java/org/apache/pulsar/io/core/SourceTest.java
@@ -28,6 +28,7 @@ import org.apache.pulsar.functions.api.Record;
import org.testng.annotations.Test;
public class SourceTest {
+ @SuppressWarnings("try")
public static class TestSource implements Source<String> {
@Override
diff --git
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicBookieCheckTest.java
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicBookieCheckTest.java
index ae7de3a47e9..d2a62f93914 100644
---
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicBookieCheckTest.java
+++
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicBookieCheckTest.java
@@ -83,11 +83,12 @@ public class AuditorPeriodicBookieCheckTest extends
BookKeeperClusterTestCase {
* Test that the periodic bookie checker works.
*/
@Test
+ @SuppressWarnings("try")
public void testPeriodicBookieCheckInterval() throws Exception {
confByIndex(0).setMetadataServiceUri(
zkUtil.getMetadataServiceUri().replaceAll("zk://",
"metadata-store:").replaceAll("/ledgers", ""));
runFunctionWithLedgerManagerFactory(confByIndex(0), mFactory -> {
- try (LedgerManager ledgerManager = mFactory.newLedgerManager()) {
+ try (LedgerManager ignored = mFactory.newLedgerManager()) {
@Cleanup final LedgerUnderreplicationManager
underReplicationManager =
mFactory.newLedgerUnderreplicationManager();
long ledgerId = 12345L;
diff --git
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorReplicasCheckTest.java
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorReplicasCheckTest.java
index 1869b1966bc..c8e102bc7bb 100644
---
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorReplicasCheckTest.java
+++
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorReplicasCheckTest.java
@@ -112,6 +112,7 @@ public class AuditorReplicasCheckTest extends
BookKeeperClusterTestCase {
super.tearDown();
}
+ @SuppressWarnings("try")
private class TestBookKeeperAdmin extends BookKeeperAdmin {
private final MultiKeyMap<String, AvailabilityOfEntriesOfLedger>
returnAvailabilityOfEntriesOfLedger;
diff --git
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
index 832f5bcbea9..c0e7fc91f2c 100644
---
a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
+++
b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
@@ -855,8 +855,9 @@ public class TestReplicationWorker extends
BookKeeperClusterTestCase {
* Test that the replication worker will not shutdown on a simple ZK
disconnection.
*/
@Test
+ @SuppressWarnings("try")
public void testRWZKConnectionLost() throws Exception {
- try (ZooKeeperClient zk = ZooKeeperClient.newBuilder()
+ try (ZooKeeperClient ignored = ZooKeeperClient.newBuilder()
.connectString(zkUtil.getZooKeeperConnectString())
.sessionTimeoutMs(10000)
.build()) {
@@ -1034,8 +1035,7 @@ public class TestReplicationWorker extends
BookKeeperClusterTestCase {
testRepairedNotAdheringPlacementPolicyLedgerFragments(
RackawareEnsemblePlacementPolicy.class, checkReplicationStats);
}
- @SuppressWarnings("deprecation")
-
+ @SuppressWarnings({"deprecation", "try"})
private void testRepairedNotAdheringPlacementPolicyLedgerFragments(
Class<? extends EnsemblePlacementPolicy> placementPolicyClass,
BiConsumer<Boolean, ReplicationWorker> checkReplicationStats)
throws Exception {
diff --git
a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/TestZKServer.java
b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/TestZKServer.java
index 8cc7b8c626d..f564a5921d3 100644
--- a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/TestZKServer.java
+++ b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/TestZKServer.java
@@ -39,6 +39,7 @@ import
org.apache.zookeeper.server.embedded.ZooKeeperServerEmbedded;
import org.assertj.core.util.Files;
@Slf4j
+@SuppressWarnings("try")
public class TestZKServer implements AutoCloseable {
public static final int TICK_TIME = 1000;
diff --git
a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java
b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java
index 2828b0de892..22c3553bf1c 100644
---
a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java
+++
b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java
@@ -93,6 +93,7 @@ public class MetadataStoreFactoryImplTest {
}
}
+ @SuppressWarnings("try")
public static class MyMetadataStore extends AbstractMetadataStore {
protected MyMetadataStore() {
super("custom", OpenTelemetry.noop(), null, 1);
diff --git
a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java
b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java
index e7b6d1b350e..7cb00f5684f 100644
---
a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java
+++
b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java
@@ -176,6 +176,7 @@ public class ProxyParserTest extends
MockedPulsarServiceBaseTest {
}
@Test
+ @SuppressWarnings("try")
public void testRegexSubscription() throws Exception {
@Cleanup
PulsarClient client =
PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
diff --git
a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java
b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java
index 7fe07361ade..d67b3d21f5f 100644
--- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java
+++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java
@@ -287,6 +287,7 @@ public class ProxyTest extends MockedPulsarServiceBaseTest {
}
@Test
+ @SuppressWarnings("try")
public void testRegexSubscription() throws Exception {
@Cleanup
PulsarClient client =
PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
@@ -398,6 +399,7 @@ public class ProxyTest extends MockedPulsarServiceBaseTest {
}
@Test
+ @SuppressWarnings("try")
public void testGetSchema() throws Exception {
@Cleanup
PulsarClient client =
PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
diff --git
a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java
b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java
index cd97954b977..9ac28d490a2 100644
---
a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java
+++
b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java
@@ -514,6 +514,7 @@ public class BlobStoreManagedLedgerOffloaderTest extends
BlobStoreManagedLedgerO
}
@Test
+ @SuppressWarnings("try")
public void testReadUnknownDataVersion() throws Exception {
@Cleanup
ReadHandle toWrite = buildReadHandle(DEFAULT_BLOCK_SIZE, 1);
diff --git
a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlockAwareSegmentInputStreamTest.java
b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlockAwareSegmentInputStreamTest.java
index 1d1fc91fd0c..6f2aba5863c 100644
---
a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlockAwareSegmentInputStreamTest.java
+++
b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlockAwareSegmentInputStreamTest.java
@@ -129,6 +129,7 @@ public class BlockAwareSegmentInputStreamTest {
}
}
+ @SuppressWarnings("try")
class MockReadHandle implements ReadHandle {
int ledgerId;
int entrySize;