Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6026,9 +6026,11 @@ public void deleteFailed(ManagedLedgerException exception, Object ctx) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,7 @@ public void addFailed(ManagedLedgerException exception, Object ctx) {
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ public void close() {

private final AtomicInteger openedReadHandles = new AtomicInteger(0);

@SuppressWarnings("try")
class VerifyClosingReadHandle extends MockOffloadReadHandle {
VerifyClosingReadHandle(ReadHandle toCopy) throws Exception {
super(toCopy);
Expand All @@ -379,6 +380,7 @@ public CompletableFuture<Void> closeAsync() {
}
}

@SuppressWarnings("try")
static class MockOffloadReadHandle implements ReadHandle, OffloadedLedgerHandle {
final long id;
final List<ByteBuf> entries = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/**
* 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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
@ToString
@Getter
@Builder(builderClassName = "Builder")
@SuppressWarnings("try")
public class PulsarTestContext implements AutoCloseable {
private final ServiceConfiguration config;
private final MetadataStoreExtended localMetadataStore;
Expand Down Expand Up @@ -709,6 +710,7 @@ private static void initializeZookeeper(ZooKeeper zk) throws KeeperException, In
CreateMode.PERSISTENT);
}

@SuppressWarnings("try")
private TestZKServer createTestZookeeper(int sessionTimeout) throws Exception {
TestZKServer testZKServer = new TestZKServer();
try (ZooKeeper zkc = new ZooKeeper(testZKServer.getConnectionString(), sessionTimeout, event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private void checkTransactionCoordinatorNum(int number) {
});
}

@SuppressWarnings("try")
private PulsarClient buildClient() throws Exception {
return PulsarClient.builder()
.serviceUrlProvider(new ServiceUrlProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,7 @@ public void testHelpFlag() throws Exception {
}
}

@SuppressWarnings("try")
private static String runCustomCommand(String[] args) throws Exception {
File narFile = new File(PulsarAdminTool.class.getClassLoader()
.getResource("cliextensions/customCommands-nar.nar").getFile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ public void testSpanWithException() {
}

@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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void testFileNotModified(String fileName) throws IOException {
}

@Test
@SuppressWarnings("try")
public void testNettyClientSslContextRefresher() throws Exception {
BasicAuthenticationData provider = new BasicAuthenticationData(null);
String certFile = "/tmp/cert.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static Object[] getCipher() {
}

@Test(dataProvider = "cipherDataProvider")
@SuppressWarnings("try")
public void testServerKeyStoreSSLContext(Set<String> cipher) throws Exception {
PulsarSslConfiguration pulsarSslConfiguration = PulsarSslConfiguration.builder()
.tlsEnabledWithKeystore(true)
Expand Down Expand Up @@ -108,6 +109,7 @@ public KeyStoreParams getTlsKeyStoreParams() {
}

@Test(dataProvider = "cipherDataProvider")
@SuppressWarnings("try")
public void testClientKeyStoreSSLContext(Set<String> cipher) throws Exception {
PulsarSslConfiguration pulsarSslConfiguration = PulsarSslConfiguration.builder()
.allowInsecureConnection(false)
Expand All @@ -125,6 +127,7 @@ public void testClientKeyStoreSSLContext(Set<String> cipher) throws Exception {
}

@Test(dataProvider = "caCertSslContextDataProvider")
@SuppressWarnings("try")
public void testServerCaCertSslContextWithSslProvider(SslProvider sslProvider, Set<String> ciphers)
throws Exception {
try (PulsarSslFactory pulsarSslFactory = new DefaultPulsarSslFactory()) {
Expand All @@ -151,6 +154,7 @@ public void testServerCaCertSslContextWithSslProvider(SslProvider sslProvider, S
}

@Test(dataProvider = "caCertSslContextDataProvider")
@SuppressWarnings("try")
public void testClientCaCertSslContextWithSslProvider(SslProvider sslProvider, Set<String> ciphers)
throws Exception {
try (PulsarSslFactory pulsarSslFactory = new DefaultPulsarSslFactory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
public class BatchSourceExecutorTest {

@SuppressWarnings("try")
public static class TestBatchSource implements BatchSource<String> {
@Getter
public static int prepareCount;
Expand Down Expand Up @@ -96,13 +97,15 @@ public void close() throws Exception {
}
}

@SuppressWarnings("try")
public static class TestBatchSourceFailDiscovery extends TestBatchSource {
@Override
public void discover(Consumer<byte[]> taskEater) throws Exception {
throw new Exception("discovery failed");
}
}

@SuppressWarnings("try")
public static class TestBatchPushSource extends BatchPushSource<String> {
@Getter
public static int prepareCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static class TestSinkConfig {
}


@SuppressWarnings("try")
public static class NopSink implements Sink<Object> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ public void testFunctionRuntimeSetCorrectly() {
}

@Test
@SuppressWarnings("try")
public void testFunctionRuntimeFactoryConfigsBackwardsCompatibility() throws Exception {

// Test kubernetes runtime
Expand Down Expand Up @@ -1148,6 +1149,7 @@ public void testThreadFunctionInstancesRestart() throws Exception {
}

@Test
@SuppressWarnings("try")
public void testKubernetesFunctionInstancesRestart() throws Exception {

WorkerConfig workerConfig = new WorkerConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Consumer;
import org.testng.annotations.Test;

@SuppressWarnings("try")
public class BatchPushSourceTest {

BatchPushSource testBatchSource = new BatchPushSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import org.testng.annotations.Test;

@SuppressWarnings("try")
public class PushSourceTest {

PushSource testBatchSource = new PushSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

public class SinkTest {

@SuppressWarnings("try")
public static class TestSink implements Sink<String> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.testng.annotations.Test;

public class SourceTest {
@SuppressWarnings("try")
public static class TestSource implements Source<String> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ public void tearDown() throws Exception {
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void tearDown() throws Exception {
super.tearDown();
}

@SuppressWarnings("try")
private class TestBookKeeperAdmin extends BookKeeperAdmin {

private final MultiKeyMap<String, AvailabilityOfEntriesOfLedger> returnAvailabilityOfEntriesOfLedger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,9 @@ public void testRWShouldReplicateTheLedgersAfterTimeoutIfLastFragmentIsNotUR()
* 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()) {
Expand Down Expand Up @@ -1034,6 +1035,7 @@ public void testReplicationStats() throws Exception {
RackawareEnsemblePlacementPolicy.class, checkReplicationStats);
}

@SuppressWarnings("try")
private void testRepairedNotAdheringPlacementPolicyLedgerFragments(
Class<? extends EnsemblePlacementPolicy> placementPolicyClass,
BiConsumer<Boolean, ReplicationWorker> checkReplicationStats) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.assertj.core.util.Files;

@Slf4j
@SuppressWarnings("try")
public class TestZKServer implements AutoCloseable {

public static final int TICK_TIME = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public MetadataStore create(String metadataURL, MetadataStoreConfig metadataStor
}
}

@SuppressWarnings("try")
public static class MyMetadataStore extends AbstractMetadataStore {
protected MyMetadataStore() {
super("custom", OpenTelemetry.noop(), null, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void testPartitions() throws Exception {
}

@Test
@SuppressWarnings("try")
public void testRegexSubscription() throws Exception {
@Cleanup
PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public void testAutoCreateTopic() throws Exception{
}

@Test
@SuppressWarnings("try")
public void testRegexSubscription() throws Exception {
@Cleanup
PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
Expand Down Expand Up @@ -397,6 +398,7 @@ public void testRegexSubscriptionWithTopicDiscovery(TopicType topicType) throws
}

@Test
@SuppressWarnings("try")
public void testGetSchema() throws Exception {
@Cleanup
PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ public void testOffloadEmpty() throws Exception {
}

@Test
@SuppressWarnings("try")
public void testReadUnknownDataVersion() throws Exception {
@Cleanup
ReadHandle toWrite = buildReadHandle(DEFAULT_BLOCK_SIZE, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public Iterator<LedgerEntry> iterator() {
}
}

@SuppressWarnings("try")
class MockReadHandle implements ReadHandle {
int ledgerId;
int entrySize;
Expand Down
Loading