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

aahmed pushed a commit to branch broker_tests_cleanup
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a4d73379e217e7924ca9c0d177143546b55b440f
Author: Ali Ahmed <alahmed...@gmail.com>
AuthorDate: Thu Aug 22 16:30:22 2019 -0700

    Fix Ccode inspection issues in pulsar borker tests
---
 .gitignore                                         |  1 +
 .../org/apache/pulsar/PulsarBrokerStarterTest.java |  8 ++--
 .../pulsar/broker/admin/v1/V1_AdminApiTest2.java   |  2 +-
 .../client/api/MessageDispatchThrottlingTest.java  |  2 -
 .../pulsar/client/api/MockBrokerServiceHooks.java  | 44 +++++++++++-----------
 .../api/PartitionedProducerConsumerTest.java       |  2 +-
 .../client/api/SimpleProducerConsumerTest.java     |  6 +--
 .../SubscriptionMessageDispatchThrottlingTest.java | 16 ++++----
 .../pulsar/client/api/TlsProducerConsumerTest.java |  6 +--
 .../client/api/v1/V1_ProducerConsumerBase.java     |  2 +-
 .../apache/pulsar/client/impl/RawReaderTest.java   |  2 +-
 .../pulsar/client/impl/TopicsConsumerImplTest.java |  2 -
 .../pulsar/client/impl/ZeroQueueSizeTest.java      |  8 +---
 .../pulsar/compaction/CompactedTopicTest.java      |  5 +--
 .../service/web/DiscoveryServiceWebTest.java       |  3 +-
 .../worker/PulsarFunctionE2ESecurityTest.java      | 12 ++++--
 .../worker/PulsarFunctionLocalRunTest.java         | 16 ++++++--
 .../worker/PulsarFunctionPublishTest.java          |  9 ++++-
 .../functions/worker/PulsarFunctionStateTest.java  |  7 +++-
 .../worker/PulsarWorkerAssignmentTest.java         | 10 +++--
 .../apache/pulsar/io/PulsarFunctionAdminTest.java  |  2 +-
 .../apache/pulsar/io/PulsarFunctionE2ETest.java    | 24 +++++-------
 .../apache/pulsar/io/PulsarFunctionTlsTest.java    | 11 ++++--
 .../pulsar/utils/SimpleTextOutputStreamTest.java   |  3 +-
 .../apache/pulsar/utils/StatsOutputStreamTest.java |  3 +-
 .../proxy/MockAuthenticationProvider.java          |  2 +-
 .../websocket/proxy/ProxyAuthenticationTest.java   |  2 +-
 .../websocket/proxy/ProxyPublishConsumeTest.java   | 12 +++---
 .../proxy/ProxyPublishConsumeTlsTest.java          |  2 +-
 .../websocket/proxy/SimpleConsumerSocket.java      |  4 +-
 .../websocket/proxy/SimpleProducerSocket.java      |  2 +-
 .../proxy/v1/V1_ProxyAuthenticationTest.java       | 20 ++++------
 32 files changed, 132 insertions(+), 118 deletions(-)

diff --git a/.gitignore b/.gitignore
index fa63e5d..c47cb93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ pulsar-broker/tmp.*
 pulsar-broker/src/test/resources/log4j2.yaml
 pulsar-functions/worker/test-tenant/
 pulsar-broker/src/test/resources/pulsar-functions-api-examples.jar
+pulsar-broker/data/
 *.log
 *.nar
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
index ba4b212..adc60d8 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
@@ -44,7 +44,7 @@ public class PulsarBrokerStarterTest {
     private File createValidBrokerConfigFile() throws FileNotFoundException {
         File testConfigFile = new File("tmp." + System.currentTimeMillis() + 
".properties");
         if (testConfigFile.exists()) {
-            testConfigFile.delete();
+            assert testConfigFile.delete();
         }
         PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(testConfigFile)));
         
printWriter.println("zookeeperServers=z1.example.com,z2.example.com,z3.example.com");
@@ -134,7 +134,7 @@ public class PulsarBrokerStarterTest {
 
         File testConfigFile = new File("tmp." + System.currentTimeMillis() + 
".properties");
         if (testConfigFile.exists()) {
-            testConfigFile.delete();
+            assert testConfigFile.delete();
         }
         PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(testConfigFile)));
         printWriter.println("brokerDeleteInactiveTopicsEnabled=false");
@@ -168,7 +168,7 @@ public class PulsarBrokerStarterTest {
 
         File testConfigFile = new File("tmp." + System.currentTimeMillis() + 
".properties");
         if (testConfigFile.exists()) {
-            testConfigFile.delete();
+            assert testConfigFile.delete();
         }
 
         PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(testConfigFile)));
@@ -217,7 +217,7 @@ public class PulsarBrokerStarterTest {
 
         File testConfigFile = new File("tmp." + System.currentTimeMillis() + 
".properties");
         if (testConfigFile.exists()) {
-            testConfigFile.delete();
+            assert testConfigFile.delete();
         }
         PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(testConfigFile)));
         
printWriter.println("zookeeperServers=z1.example.com,z2.example.com,z3.example.com");
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest2.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest2.java
index 76244df..edaf669 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest2.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest2.java
@@ -452,7 +452,7 @@ public class V1_AdminApiTest2 extends 
MockedPulsarServiceBaseTest {
             }
         }
 
-        // close consumer which will clean up intenral-receive-queue
+        // close consumer which will clean up internal-receive-queue
         consumer.close();
 
         // messages should still be available due to retention
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MessageDispatchThrottlingTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MessageDispatchThrottlingTest.java
index cc0f46e..5bcc985 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MessageDispatchThrottlingTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MessageDispatchThrottlingTest.java
@@ -225,8 +225,6 @@ public class MessageDispatchThrottlingTest extends 
ProducerConsumerBase {
     /**
      * It verifies that dispatch-rate throttling with cluster-configuration
      *
-     * @param subscription
-     * @param dispatchRateType
      * @throws Exception
      */
     @Test()
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MockBrokerServiceHooks.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MockBrokerServiceHooks.java
index 743af88..5f940a6 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MockBrokerServiceHooks.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/MockBrokerServiceHooks.java
@@ -26,47 +26,47 @@ import io.netty.channel.ChannelHandlerContext;
 /**
  */
 public interface MockBrokerServiceHooks {
-    public interface CommandConnectHook {
-        public void apply(ChannelHandlerContext ctx, PulsarApi.CommandConnect 
connect);
+    interface CommandConnectHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandConnect 
connect);
     }
 
-    public interface CommandPartitionLookupHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandPartitionedTopicMetadata connect);
+    interface CommandPartitionLookupHook {
+        void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandPartitionedTopicMetadata connect);
     }
 
-    public interface CommandTopicLookupHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandLookupTopic connect);
+    interface CommandTopicLookupHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandLookupTopic 
connect);
     }
 
-    public interface CommandSubscribeHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandSubscribe subscribe);
+    interface CommandSubscribeHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandSubscribe 
subscribe);
     }
 
-    public interface CommandProducerHook {
-        public void apply(ChannelHandlerContext ctx, PulsarApi.CommandProducer 
producer);
+    interface CommandProducerHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandProducer 
producer);
     }
 
-    public interface CommandSendHook {
-        public void apply(ChannelHandlerContext ctx, PulsarApi.CommandSend 
send, ByteBuf headersAndPayload);
+    interface CommandSendHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandSend send, 
ByteBuf headersAndPayload);
     }
 
-    public interface CommandAckHook {
-        public void apply(ChannelHandlerContext ctx, PulsarApi.CommandAck ack);
+    interface CommandAckHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandAck ack);
     }
 
-    public interface CommandFlowHook {
-        public void apply(ChannelHandlerContext ctx, PulsarApi.CommandFlow 
flow);
+    interface CommandFlowHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandFlow flow);
     }
 
-    public interface CommandUnsubscribeHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandUnsubscribe unsubscribe);
+    interface CommandUnsubscribeHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandUnsubscribe 
unsubscribe);
     }
 
-    public interface CommandCloseProducerHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandCloseProducer closeProducer);
+    interface CommandCloseProducerHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandCloseProducer 
closeProducer);
     }
 
-    public interface CommandCloseConsumerHook {
-        public void apply(ChannelHandlerContext ctx, 
PulsarApi.CommandCloseConsumer closeConsumer);
+    interface CommandCloseConsumerHook {
+        void apply(ChannelHandlerContext ctx, PulsarApi.CommandCloseConsumer 
closeConsumer);
     }
 }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionedProducerConsumerTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionedProducerConsumerTest.java
index 9820056..f65076d 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionedProducerConsumerTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionedProducerConsumerTest.java
@@ -846,7 +846,7 @@ public class PartitionedProducerConsumerTest extends 
ProducerConsumerBase {
     }
 
 
-    private class AlwaysTwoMessageRouter implements MessageRouter {
+    private static class AlwaysTwoMessageRouter implements MessageRouter {
         @Override
         public int choosePartition(Message<?> msg, TopicMetadata metadata) {
             return 2;
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java
index 35d4c77..e8619ed 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java
@@ -1181,14 +1181,14 @@ public class SimpleProducerConsumerTest extends 
ProducerConsumerBase {
             consumerMsgSet2.add(msg);
         }
 
-        consumerMsgSet1.stream().forEach(m -> {
+        consumerMsgSet1.forEach(m -> {
             try {
                 consumer2.acknowledge(m);
             } catch (PulsarClientException e) {
                 fail();
             }
         });
-        consumerMsgSet2.stream().forEach(m -> {
+        consumerMsgSet2.forEach(m -> {
             try {
                 consumer1.acknowledge(m);
             } catch (PulsarClientException e) {
@@ -1400,7 +1400,6 @@ public class SimpleProducerConsumerTest extends 
ProducerConsumerBase {
      * Verify: Consumer1 which doesn't send ack will not impact Consumer2 
which sends ack for consumed message.
      *
      *
-     * @param batchMessageDelayMs
      * @throws Exception
      */
     @Test
@@ -1717,7 +1716,6 @@ public class SimpleProducerConsumerTest extends 
ProducerConsumerBase {
      * Verify: Consumer2 sends ack of Consumer1 and consumer1 should be 
unblock if it is blocked due to unack-messages
      *
      *
-     * @param batchMessageDelayMs
      * @throws Exception
      */
     @Test
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SubscriptionMessageDispatchThrottlingTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SubscriptionMessageDispatchThrottlingTest.java
index cbcef08..e4aff1e 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SubscriptionMessageDispatchThrottlingTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SubscriptionMessageDispatchThrottlingTest.java
@@ -488,9 +488,9 @@ public class SubscriptionMessageDispatchThrottlingTest 
extends MessageDispatchTh
         DispatchRateLimiter subRateLimiter = null;
         Dispatcher subDispatcher = 
topic.getSubscription(subName1).getDispatcher();
         if (subDispatcher instanceof PersistentDispatcherMultipleConsumers) {
-            subRateLimiter = ((PersistentDispatcherMultipleConsumers) 
subDispatcher).getRateLimiter().get();
+            subRateLimiter = subDispatcher.getRateLimiter().get();
         } else if (subDispatcher instanceof 
PersistentDispatcherSingleActiveConsumer) {
-            subRateLimiter = ((PersistentDispatcherSingleActiveConsumer) 
subDispatcher).getRateLimiter().get();
+            subRateLimiter = subDispatcher.getRateLimiter().get();
         } else {
             Assert.fail("Should only have PersistentDispatcher in this test");
         }
@@ -504,10 +504,10 @@ public class SubscriptionMessageDispatchThrottlingTest 
extends MessageDispatchTh
         admin.namespaces().setSubscriptionDispatchRate(namespace, 
dispatchRate);
 
         if (subDispatcher instanceof PersistentDispatcherMultipleConsumers) {
-            subRateLimiter = ((PersistentDispatcherMultipleConsumers) 
subDispatcher).getRateLimiter().get();
-        } else if (subDispatcher instanceof 
PersistentDispatcherSingleActiveConsumer) {
-            subRateLimiter = ((PersistentDispatcherSingleActiveConsumer) 
subDispatcher).getRateLimiter().get();
-        } else {
+            subRateLimiter = subDispatcher.getRateLimiter().get();
+        } else if (subDispatcher instanceof 
PersistentDispatcherSingleActiveConsumer)
+            subRateLimiter = subDispatcher.getRateLimiter().get();
+        else {
             Assert.fail("Should only have PersistentDispatcher in this test");
         }
 
@@ -536,9 +536,9 @@ public class SubscriptionMessageDispatchThrottlingTest 
extends MessageDispatchTh
 
         subDispatcher = topic2.getSubscription(subName2).getDispatcher();
         if (subDispatcher instanceof PersistentDispatcherMultipleConsumers) {
-            subRateLimiter = ((PersistentDispatcherMultipleConsumers) 
subDispatcher).getRateLimiter().get();
+            subRateLimiter = subDispatcher.getRateLimiter().get();
         } else if (subDispatcher instanceof 
PersistentDispatcherSingleActiveConsumer) {
-            subRateLimiter = ((PersistentDispatcherSingleActiveConsumer) 
subDispatcher).getRateLimiter().get();
+            subRateLimiter = subDispatcher.getRateLimiter().get();
         } else {
             Assert.fail("Should only have PersistentDispatcher in this test");
         }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TlsProducerConsumerTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TlsProducerConsumerTest.java
index d506527..ab33060 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TlsProducerConsumerTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TlsProducerConsumerTest.java
@@ -40,7 +40,7 @@ public class TlsProducerConsumerTest extends 
TlsProducerConsumerBase {
         log.info("-- Starting {} test --", methodName);
 
         final int MESSAGE_SIZE = 16 * 1024 + 1;
-        log.info("-- message size --", MESSAGE_SIZE);
+        log.info("-- message size -- {}", MESSAGE_SIZE);
 
         internalSetUpForClient(true, "pulsar+ssl://localhost:" + 
BROKER_PORT_TLS);
         internalSetUpForNamespace();
@@ -74,7 +74,7 @@ public class TlsProducerConsumerTest extends 
TlsProducerConsumerBase {
         log.info("-- Starting {} test --", methodName);
 
         final int MESSAGE_SIZE = 16 * 1024 + 1;
-        log.info("-- message size --", MESSAGE_SIZE);
+        log.info("-- message size -- {}", MESSAGE_SIZE);
         internalSetUpForNamespace();
 
         // Test 1 - Using TLS on binary protocol without sending certs - 
expect failure
@@ -102,7 +102,7 @@ public class TlsProducerConsumerTest extends 
TlsProducerConsumerBase {
         log.info("-- Starting {} test --", methodName);
 
         final int MESSAGE_SIZE = 16 * 1024 + 1;
-        log.info("-- message size --", MESSAGE_SIZE);
+        log.info("-- message size -- {}", MESSAGE_SIZE);
         internalSetUpForNamespace();
 
         // Test 1 - Using TLS on https without sending certs - expect failure
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerBase.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerBase.java
index d38da4f..a6c5a3b 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerBase.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerBase.java
@@ -33,7 +33,7 @@ public abstract class V1_ProducerConsumerBase extends 
MockedPulsarServiceBaseTes
     protected String methodName;
 
     @BeforeMethod
-    public void beforeMethod(Method m) throws Exception {
+    public void beforeMethod(Method m) {
         methodName = m.getName();
     }
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
index 5085763..a675e61 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
@@ -94,7 +94,7 @@ public class RawReaderTest extends 
MockedPulsarServiceBaseTest {
         return keys;
     }
 
-    public static String extractKey(RawMessage m) throws Exception {
+    public static String extractKey(RawMessage m) {
         ByteBuf headersAndPayload = m.getHeadersAndPayload();
         MessageMetadata msgMetadata = 
Commands.parseMessageMetadata(headersAndPayload);
         return msgMetadata.getPartitionKey();
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java
index f2eaca9..64ef84d 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java
@@ -672,8 +672,6 @@ public class TopicsConsumerImplTest extends 
ProducerConsumerBase {
             .subscribe();
         assertTrue(consumer instanceof MultiTopicsConsumerImpl);
 
-        MultiTopicsConsumerImpl topicsConsumer = (MultiTopicsConsumerImpl) 
consumer;
-
         // 3. producer publish messages
         for (int i = 0; i < totalMessages; i++) {
             producer1.send((messagePredicate + "producer1-" + i).getBytes());
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java
index 2859047..8a059f6 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java
@@ -278,12 +278,8 @@ public class ZeroQueueSizeTest extends BrokerTestBase {
             .topic("persistent://prop-xyz/use/ns-abc/topic1")
             .messageRoutingMode(MessageRoutingMode.SinglePartition);
 
-        if (batchMessageDelayMs != 0) {
-            
producerBuilder.enableBatching(true).batchingMaxPublishDelay(batchMessageDelayMs,
 TimeUnit.MILLISECONDS)
-                    .batchingMaxMessages(5);
-        } else {
-            producerBuilder.enableBatching(false);
-        }
+        
producerBuilder.enableBatching(true).batchingMaxPublishDelay(batchMessageDelayMs,
 TimeUnit.MILLISECONDS)
+                .batchingMaxMessages(5);
 
         Producer<byte[]> producer = producerBuilder.create();
         for (int i = 0; i < 10; i++) {
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java
index 504de2a..5712ca8 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java
@@ -179,14 +179,13 @@ public class CompactedTopicTest extends 
MockedPulsarServiceBaseTest {
         for (Pair<MessageIdData, Long> p : positions) {
             PositionImpl pos = new PositionImpl(p.getLeft().getLedgerId(), 
p.getLeft().getEntryId());
             Long got = CompactedTopicImpl.findStartPoint(pos, lastEntryId, 
cache).get();
-            Assert.assertEquals(got, Long.valueOf(p.getRight()));
+            Assert.assertEquals(got, p.getRight());
         }
 
         // Check ids we know are in the gaps of the compacted ledger
         for (Pair<MessageIdData, Long> gap : idsInGaps) {
             PositionImpl pos = new PositionImpl(gap.getLeft().getLedgerId(), 
gap.getLeft().getEntryId());
-            Assert.assertEquals(CompactedTopicImpl.findStartPoint(pos, 
lastEntryId, cache).get(),
-                                Long.valueOf(gap.getRight()));
+            Assert.assertEquals(CompactedTopicImpl.findStartPoint(pos, 
lastEntryId, cache).get(), gap.getRight());
         }
     }
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
index 3300f6c..be5a274 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
@@ -130,8 +130,7 @@ public class DiscoveryServiceWebTest extends 
ProducerConsumerBase {
         }
 
         JsonObject jsonObject = new 
Gson().fromJson(response.readEntity(String.class), JsonObject.class);
-        String serviceResponse = jsonObject.get("reason").getAsString();
-        return serviceResponse;
+        return jsonObject.get("reason").getAsString();
     }
 
     static class DiscoveryZooKeeperClientFactoryImpl implements 
ZooKeeperClientFactory {
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionE2ESecurityTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionE2ESecurityTest.java
index 54f05d8..263265b 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionE2ESecurityTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionE2ESecurityTest.java
@@ -118,7 +118,7 @@ public class PulsarFunctionE2ESecurityTest {
         log.info("--- Setting up method {} ---", method.getName());
 
         // Start local bookkeeper ensemble
-        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, () -> 
PortManager.nextFreePort());
+        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 
PortManager::nextFreePort);
         bkEnsemble.start();
 
         brokerServiceUrl = "http://127.0.0.1:"; + brokerWebServicePort;
@@ -246,7 +246,12 @@ public class PulsarFunctionE2ESecurityTest {
         return new WorkerService(workerConfig);
     }
 
-    protected static FunctionConfig createFunctionConfig(String tenant, String 
namespace, String functionName, String sourceTopic, String sinkTopic, String 
subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String sinkTopic,
+                                                         String 
subscriptionName) {
 
         FunctionConfig functionConfig = new FunctionConfig();
         functionConfig.setTenant(tenant);
@@ -281,7 +286,8 @@ public class PulsarFunctionE2ESecurityTest {
                 PulsarAdmin.builder().serviceHttpUrl(brokerServiceUrl).build())
         ) {
 
-            String jarFilePathUrl = Utils.FILE + ":" + 
getClass().getClassLoader().getResource("pulsar-functions-api-examples.jar").getFile();
+            String jarFilePathUrl = Utils.FILE + ":" +
+                    
getClass().getClassLoader().getResource("pulsar-functions-api-examples.jar").getFile();
 
             FunctionConfig functionConfig = createFunctionConfig(TENANT, 
NAMESPACE, functionName,
                     sourceTopic, sinkTopic, subscriptionName);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionLocalRunTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionLocalRunTest.java
index 97cabc3..543ba66 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionLocalRunTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionLocalRunTest.java
@@ -139,13 +139,13 @@ public class PulsarFunctionLocalRunTest {
         File[] foundFiles = dir.listFiles((ignoredDir, name) -> 
name.startsWith("function"));
 
         for (File file : foundFiles) {
-            file.delete();
+            assert file.delete();
         }
 
         log.info("--- Setting up method {} ---", method.getName());
 
         // Start local bookkeeper ensemble
-        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, () -> 
PortManager.nextFreePort());
+        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 
PortManager::nextFreePort);
         bkEnsemble.start();
 
         String brokerServiceUrl = "https://127.0.0.1:"; + 
brokerWebServiceTlsPort;
@@ -330,7 +330,12 @@ public class PulsarFunctionLocalRunTest {
         return new WorkerService(workerConfig);
     }
 
-    protected static FunctionConfig createFunctionConfig(String tenant, String 
namespace, String functionName, String sourceTopic, String sinkTopic, String 
subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String sinkTopic,
+                                                         String 
subscriptionName) {
 
         FunctionConfig functionConfig = new FunctionConfig();
         functionConfig.setTenant(tenant);
@@ -348,7 +353,10 @@ public class PulsarFunctionLocalRunTest {
         return functionConfig;
     }
 
-    private static SourceConfig createSourceConfig(String tenant, String 
namespace, String functionName, String sinkTopic) {
+    private static SourceConfig createSourceConfig(String tenant,
+                                                   String namespace,
+                                                   String functionName,
+                                                   String sinkTopic) {
         SourceConfig sourceConfig = new SourceConfig();
         sourceConfig.setTenant(tenant);
         sourceConfig.setNamespace(namespace);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionPublishTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionPublishTest.java
index 9c2b7b7..081d328 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionPublishTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionPublishTest.java
@@ -124,7 +124,7 @@ public class PulsarFunctionPublishTest {
         File[] foundFiles = dir.listFiles((ignoredDir, name) -> 
name.startsWith("function"));
 
         for (File file : foundFiles) {
-            file.delete();
+            assert file.delete();
         }
 
         log.info("--- Setting up method {} ---", method.getName());
@@ -264,7 +264,12 @@ public class PulsarFunctionPublishTest {
         return new WorkerService(workerConfig);
     }
 
-    protected static FunctionConfig createFunctionConfig(String tenant, String 
namespace, String functionName, String sourceTopic, String publishTopic, String 
subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String publishTopic,
+                                                         String 
subscriptionName) {
 
         FunctionConfig functionConfig = new FunctionConfig();
         functionConfig.setTenant(tenant);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionStateTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionStateTest.java
index 809fca7..f5c974e 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionStateTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionStateTest.java
@@ -262,7 +262,12 @@ public class PulsarFunctionStateTest {
         return new WorkerService(workerConfig);
     }
 
-    protected static FunctionConfig createFunctionConfig(String tenant, String 
namespace, String functionName, String sourceTopic, String sinkTopic, String 
subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String sinkTopic,
+                                                         String 
subscriptionName) {
 
         FunctionConfig functionConfig = new FunctionConfig();
         functionConfig.setTenant(tenant);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarWorkerAssignmentTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarWorkerAssignmentTest.java
index 55e4a70..b56a0d9 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarWorkerAssignmentTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarWorkerAssignmentTest.java
@@ -87,7 +87,7 @@ public class PulsarWorkerAssignmentTest {
         log.info("--- Setting up method {} ---", method.getName());
 
         // Start local bookkeeper ensemble
-        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, () -> 
PortManager.nextFreePort());
+        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 
PortManager::nextFreePort);
         bkEnsemble.start();
 
         final String brokerServiceUrl = "http://127.0.0.1:"; + 
brokerServicePort;
@@ -313,8 +313,12 @@ public class PulsarWorkerAssignmentTest {
         }
     }
 
-    protected static FunctionConfig createFunctionConfig(String tenant, String 
namespace,
-                                                         String functionName, 
String sourceTopic, String sinkTopic, String subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String sinkTopic,
+                                                         String 
subscriptionName) {
 
         final String sourceTopicPattern = 
String.format("persistent://%s/%s/%s", tenant, namespace, sourceTopic);
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionAdminTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionAdminTest.java
index ecfce1c..1675d72 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionAdminTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionAdminTest.java
@@ -95,7 +95,7 @@ public class PulsarFunctionAdminTest {
         log.info("--- Setting up method {} ---", method.getName());
 
         // Start local bookkeeper ensemble
-        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, () -> 
PortManager.nextFreePort());
+        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 
PortManager::nextFreePort);
         bkEnsemble.start();
 
         String brokerServiceUrl = "https://127.0.0.1:"; + 
brokerWebServiceTlsPort;
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionE2ETest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionE2ETest.java
index 847958f..abe25a9 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionE2ETest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionE2ETest.java
@@ -96,11 +96,7 @@ import static 
org.apache.commons.lang3.StringUtils.isNotBlank;
 import static 
org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.retryStrategically;
 import static 
org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY;
 import static org.mockito.Mockito.spy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.*;
 
 /**
  * Test Pulsar sink on function
@@ -153,7 +149,7 @@ public class PulsarFunctionE2ETest {
         File[] foundFiles = dir.listFiles((dir1, name) -> 
name.startsWith("function"));
 
         for (File file : foundFiles) {
-            file.delete();
+            assert file.delete();
         }
 
         log.info("--- Setting up method {} ---", method.getName());
@@ -924,14 +920,14 @@ public class PulsarFunctionE2ETest {
         assertEquals(functionStats.getProcessedSuccessfullyTotal(), 0);
         assertEquals(functionStats.getSystemExceptionsTotal(), 0);
         assertEquals(functionStats.getUserExceptionsTotal(), 0);
-        assertEquals(functionStats.avgProcessLatency, null);
+        assertNull(functionStats.avgProcessLatency);
         assertEquals(functionStats.oneMin.getReceivedTotal(), 0);
         assertEquals(functionStats.oneMin.getProcessedSuccessfullyTotal(), 0);
         assertEquals(functionStats.oneMin.getSystemExceptionsTotal(), 0);
         assertEquals(functionStats.oneMin.getUserExceptionsTotal(), 0);
-        assertEquals(functionStats.oneMin.getAvgProcessLatency(), null);
+        assertNull(functionStats.oneMin.getAvgProcessLatency());
         assertEquals(functionStats.getAvgProcessLatency(), 
functionStats.oneMin.getAvgProcessLatency());
-        assertEquals(functionStats.getLastInvocation(), null);
+        assertNull(functionStats.getLastInvocation());
 
         assertEquals(functionStats.instances.size(), 1);
         assertEquals(functionStats.instances.get(0).getInstanceId(), 0);
@@ -939,12 +935,12 @@ public class PulsarFunctionE2ETest {
         
assertEquals(functionStats.instances.get(0).getMetrics().getProcessedSuccessfullyTotal(),
 0);
         
assertEquals(functionStats.instances.get(0).getMetrics().getSystemExceptionsTotal(),
 0);
         
assertEquals(functionStats.instances.get(0).getMetrics().getUserExceptionsTotal(),
 0);
-        
assertEquals(functionStats.instances.get(0).getMetrics().avgProcessLatency, 
null);
+        
assertNull(functionStats.instances.get(0).getMetrics().avgProcessLatency);
         
assertEquals(functionStats.instances.get(0).getMetrics().oneMin.getReceivedTotal(),
 0);
         
assertEquals(functionStats.instances.get(0).getMetrics().oneMin.getProcessedSuccessfullyTotal(),
 0);
         
assertEquals(functionStats.instances.get(0).getMetrics().oneMin.getSystemExceptionsTotal(),
 0);
         
assertEquals(functionStats.instances.get(0).getMetrics().oneMin.getUserExceptionsTotal(),
 0);
-        
assertEquals(functionStats.instances.get(0).getMetrics().oneMin.getAvgProcessLatency(),
 null);
+        
assertNull(functionStats.instances.get(0).getMetrics().oneMin.getAvgProcessLatency());
 
         
assertEquals(functionStats.instances.get(0).getMetrics().getAvgProcessLatency(),
 functionStats.instances.get(0).getMetrics().oneMin.getAvgProcessLatency());
         
assertEquals(functionStats.instances.get(0).getMetrics().getAvgProcessLatency(),
 functionStats.getAvgProcessLatency());
@@ -1512,7 +1508,7 @@ public class PulsarFunctionE2ETest {
         retryStrategically((test) -> {
             try {
                 FunctionConfig result = admin.functions().getFunction(tenant, 
namespacePortion, functionName);
-                return result.getParallelism() == 2 && 
result.getCleanupSubscription() == false;
+                return result.getParallelism() == 2 && 
!result.getCleanupSubscription();
             } catch (PulsarAdminException e) {
                 return false;
             }
@@ -1526,7 +1522,7 @@ public class PulsarFunctionE2ETest {
         retryStrategically((test) -> {
             try {
                 FunctionConfig result = admin.functions().getFunction(tenant, 
namespacePortion, functionName);
-                return result.getParallelism() == 2 && 
result.getCleanupSubscription() == false;
+                return result.getParallelism() == 2 && 
!result.getCleanupSubscription();
             } catch (PulsarAdminException e) {
                 return false;
             }
@@ -1583,7 +1579,7 @@ public class PulsarFunctionE2ETest {
             checkArgument(matcher.matches());
             String name = matcher.group(1);
             Metric m = new Metric();
-            m.value = Double.valueOf(matcher.group(3));
+            m.value = Double.parseDouble(matcher.group(3));
             String tags = matcher.group(2);
             Matcher tagsMatcher = tagsPattern.matcher(tags);
             while (tagsMatcher.find()) {
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionTlsTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionTlsTest.java
index 41782a4..930ecaf 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionTlsTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/io/PulsarFunctionTlsTest.java
@@ -94,7 +94,7 @@ public class PulsarFunctionTlsTest {
         log.info("--- Setting up method {} ---", method.getName());
 
         // Start local bookkeeper ensemble
-        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, () -> 
PortManager.nextFreePort());
+        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 
PortManager::nextFreePort);
         bkEnsemble.start();
 
         config = spy(new ServiceConfiguration());
@@ -222,7 +222,13 @@ public class PulsarFunctionTlsTest {
 
     }
 
-    protected static FunctionConfig createFunctionConfig(String jarFile, 
String tenant, String namespace, String functionName, String sourceTopic, 
String sinkTopic, String subscriptionName) {
+    protected static FunctionConfig createFunctionConfig(String jarFile,
+                                                         String tenant,
+                                                         String namespace,
+                                                         String functionName,
+                                                         String sourceTopic,
+                                                         String sinkTopic,
+                                                         String 
subscriptionName) {
 
         File file = new File(jarFile);
         try {
@@ -231,7 +237,6 @@ public class PulsarFunctionTlsTest {
             throw new RuntimeException("Failed to load user jar " + file, e);
         }
         String sourceTopicPattern = String.format("persistent://%s/%s/%s", 
tenant, namespace, sourceTopic);
-        Class<?> typeArg = byte[].class;
 
         FunctionConfig functionConfig = new FunctionConfig();
         functionConfig.setTenant(tenant);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/utils/SimpleTextOutputStreamTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/utils/SimpleTextOutputStreamTest.java
index 030ff30..8669107 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/utils/SimpleTextOutputStreamTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/utils/SimpleTextOutputStreamTest.java
@@ -21,6 +21,7 @@ package org.apache.pulsar.utils;
 import static org.testng.Assert.assertEquals;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.pulsar.common.util.SimpleTextOutputStream;
 import org.testng.annotations.BeforeMethod;
@@ -113,7 +114,7 @@ public class SimpleTextOutputStreamTest {
     }
 
     public String str() {
-        String s = buf.toString(Charset.forName("utf-8"));
+        String s = buf.toString(StandardCharsets.UTF_8);
         reset();
         return s;
     }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/utils/StatsOutputStreamTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/utils/StatsOutputStreamTest.java
index a89fa1a..47bfa27 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/utils/StatsOutputStreamTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/utils/StatsOutputStreamTest.java
@@ -24,6 +24,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -145,7 +146,7 @@ public class StatsOutputStreamTest {
     }
 
     public String str() {
-        String s = buf.toString(Charset.forName("utf-8"));
+        String s = buf.toString(StandardCharsets.UTF_8);
         reset();
         return s;
     }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/MockAuthenticationProvider.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/MockAuthenticationProvider.java
index 635572f..afa6bbb 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/MockAuthenticationProvider.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/MockAuthenticationProvider.java
@@ -35,7 +35,7 @@ public class MockAuthenticationProvider implements 
AuthenticationProvider {
     }
 
     @Override
-    public void initialize(ServiceConfiguration config) throws IOException {
+    public void initialize(ServiceConfiguration config) {
 
     }
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java
index 725cad5..7d03cf7 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java
@@ -214,7 +214,7 @@ public class ProxyAuthenticationTest extends 
ProducerConsumerBase {
     private void verifyResponseStatus(Client client, String url) {
         WebTarget webTarget = client.target(url);
         Invocation.Builder invocationBuilder = 
webTarget.request(MediaType.APPLICATION_JSON);
-        Response response = (Response) invocationBuilder.get();
+        Response response = invocationBuilder.get();
         Assert.assertEquals(response.getStatus(), 200);
     }
 
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java
index 7707903..0b17a86 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java
@@ -185,9 +185,9 @@ public class ProxyPublishConsumeTest extends 
ProducerConsumerBase {
     }
 
     @Test(timeOut = 10000)
-    public void emptySubcriptionConsumerTest() throws Exception {
+    public void emptySubcriptionConsumerTest() {
 
-        // Empty subcription name
+        // Empty subscription name
         final String consumerUri = "ws://localhost:" + port
                 + 
"/ws/v2/consumer/persistent/my-property/my-ns/my-topic2/?subscriptionType=Exclusive";
         URI consumeUri = URI.create(consumerUri);
@@ -534,7 +534,7 @@ public class ProxyPublishConsumeTest extends 
ProducerConsumerBase {
         String statUrl = baseUrl + topic + "/stats";
         WebTarget webTarget = client.target(statUrl);
         Invocation.Builder invocationBuilder = 
webTarget.request(MediaType.APPLICATION_JSON);
-        Response response = (Response) invocationBuilder.get();
+        Response response = invocationBuilder.get();
         String responseStr = response.readEntity(String.class);
         final Gson gson = new Gson();
         final ProxyTopicStat data = gson.fromJson(responseStr, 
ProxyTopicStat.class);
@@ -549,7 +549,7 @@ public class ProxyPublishConsumeTest extends 
ProducerConsumerBase {
         String statUrl = baseUrl + "metrics";
         WebTarget webTarget = client.target(statUrl);
         Invocation.Builder invocationBuilder = 
webTarget.request(MediaType.APPLICATION_JSON);
-        Response response = (Response) invocationBuilder.get();
+        Response response = invocationBuilder.get();
         String responseStr = response.readEntity(String.class);
         final Gson gson = new Gson();
         List<Metrics> data = gson.fromJson(responseStr, new 
TypeToken<List<Metrics>>() {
@@ -558,7 +558,7 @@ public class ProxyPublishConsumeTest extends 
ProducerConsumerBase {
         // re-generate metrics
         service.getProxyStats().generate();
         invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
-        response = (Response) invocationBuilder.get();
+        response = invocationBuilder.get();
         responseStr = response.readEntity(String.class);
         data = gson.fromJson(responseStr, new TypeToken<List<Metrics>>() {
         }.getType());
@@ -570,7 +570,7 @@ public class ProxyPublishConsumeTest extends 
ProducerConsumerBase {
         String statUrl = baseUrl + "stats";
         WebTarget webTarget = client.target(statUrl);
         Invocation.Builder invocationBuilder = 
webTarget.request(MediaType.APPLICATION_JSON);
-        Response response = (Response) invocationBuilder.get();
+        Response response = invocationBuilder.get();
         String responseStr = response.readEntity(String.class);
         final Gson gson = new Gson();
         final Map<String, ProxyTopicStat> data = gson.fromJson(responseStr,
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java
index ed9d25b..f686dd6 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java
@@ -93,7 +93,7 @@ public class ProxyPublishConsumeTlsTest extends 
TlsProducerConsumerBase {
     }
 
     @Test(timeOut = 30000)
-    public void socketTest() throws InterruptedException, 
GeneralSecurityException {
+    public void socketTest() throws GeneralSecurityException {
         String consumerUri =
                 "wss://localhost:" + tlsPort + 
"/ws/consumer/persistent/my-property/use/my-ns/my-topic/my-sub";
         String producerUri = "wss://localhost:" + tlsPort + 
"/ws/producer/persistent/my-property/use/my-ns/my-topic/";
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleConsumerSocket.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleConsumerSocket.java
index c303ed5..e133ce2 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleConsumerSocket.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleConsumerSocket.java
@@ -48,7 +48,7 @@ public class SimpleConsumerSocket {
 
     public SimpleConsumerSocket() {
         this.closeLatch = new CountDownLatch(1);
-        consumerBuffer = new ArrayList<String>();
+        consumerBuffer = new ArrayList<>();
     }
 
     public boolean awaitClose(int duration, TimeUnit unit) throws 
InterruptedException {
@@ -63,7 +63,7 @@ public class SimpleConsumerSocket {
     }
 
     @OnWebSocketConnect
-    public void onConnect(Session session) throws InterruptedException {
+    public void onConnect(Session session) {
         log.info("Got connect: {}", session);
         this.session = session;
         log.debug("Got connected: {}", session);
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleProducerSocket.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleProducerSocket.java
index db8e5bf..149e46b 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleProducerSocket.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/SimpleProducerSocket.java
@@ -49,7 +49,7 @@ public class SimpleProducerSocket {
 
     public SimpleProducerSocket() {
         this.closeLatch = new CountDownLatch(1);
-        producerBuffer = new ArrayList<String>();
+        producerBuffer = new ArrayList<>();
     }
 
     private static String getTestJsonPayload(int index) throws 
JsonProcessingException {
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java
index 48ff28c..ff9bd24 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java
@@ -147,28 +147,22 @@ public class V1_ProxyAuthenticationTest extends 
V1_ProducerConsumerBase {
         Assert.assertEquals(produceSocket.getBuffer(), 
consumeSocket.getBuffer());
     }
 
-    @Test(timeOut=10000)
+    @Test(timeOut = 10000)
     public void authenticatedSocketTest() throws Exception {
         socketTest();
     }
 
-    @Test(timeOut=10000)
+    @Test(timeOut = 10000)
     public void anonymousSocketTest() throws Exception {
         socketTest();
     }
 
-    @Test(timeOut=10000)
-    public void unauthenticatedSocketTest() throws Exception{
-        Exception exception = null;
-        try {
-            socketTest();
-        } catch (Exception e) {
-            exception = e;
-        }
-        Assert.assertTrue(exception instanceof 
java.util.concurrent.ExecutionException);
+    @Test(timeOut = 10000, expectedExceptions = 
java.util.concurrent.ExecutionException.class)
+    public void unauthenticatedSocketTest() throws Exception {
+        socketTest();
     }
 
-    @Test(timeOut=10000)
+    @Test(timeOut = 10000)
     public void statsTest() throws Exception {
         final String topic = "prop/use/my-ns/my-topic2";
         final String consumerUri = "ws://localhost:" + port + 
"/ws/consumer/persistent/" + topic + "/my-sub";
@@ -219,7 +213,7 @@ public class V1_ProxyAuthenticationTest extends 
V1_ProducerConsumerBase {
     private void verifyResponseStatus(Client client, String url) {
         WebTarget webTarget = client.target(url);
         Invocation.Builder invocationBuilder = 
webTarget.request(MediaType.APPLICATION_JSON);
-        Response response = (Response) invocationBuilder.get();
+        Response response = invocationBuilder.get();
         Assert.assertEquals(response.getStatus(), 200);
     }
 

Reply via email to