diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyEncryptionPublishConsumeTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyEncryptionPublishConsumeTest.java index 041107e5e93d7..cf7304615f5be 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyEncryptionPublishConsumeTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyEncryptionPublishConsumeTest.java @@ -73,7 +73,7 @@ public void setup() throws Exception { config.setClusterName("test"); config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); config.setCryptoKeyReaderFactoryClassName(CryptoKeyReaderFactoryImpl.class.getName()); - WebSocketService service = spy(new WebSocketService(config)); + service = spy(new WebSocketService(config)); doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(service) .createConfigMetadataStore(anyString(), anyInt(), anyBoolean()); proxyServer = new ProxyServer(config); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeClientSideEncryptionTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeClientSideEncryptionTest.java index e36d9d2a194e2..16936d65fc22b 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeClientSideEncryptionTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeClientSideEncryptionTest.java @@ -77,7 +77,7 @@ public void setup() throws Exception { config.setWebServicePort(Optional.of(0)); config.setClusterName("test"); config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); - WebSocketService service = spy(new WebSocketService(config)); + service = spy(new WebSocketService(config)); doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(service) .createConfigMetadataStore(anyString(), anyInt(), anyBoolean()); proxyServer = new ProxyServer(config); diff --git a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/AbstractWebSocketHandlerTest.java b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/AbstractWebSocketHandlerTest.java index eec2c3d1baa6b..7ec6faf634263 100644 --- a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/AbstractWebSocketHandlerTest.java +++ b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/AbstractWebSocketHandlerTest.java @@ -37,6 +37,7 @@ import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import lombok.Cleanup; import lombok.Getter; import org.apache.pulsar.broker.authentication.AuthenticationDataSource; import org.apache.pulsar.client.api.CompressionType; @@ -388,10 +389,11 @@ public void consumerBuilderTest() throws IOException { } @Test - public void testPingFuture() { + public void testPingFuture() throws IOException { WebSocketProxyConfiguration webSocketProxyConfiguration = new WebSocketProxyConfiguration(); webSocketProxyConfiguration.setWebSocketPingDurationSeconds(5); + @Cleanup WebSocketService webSocketService = new WebSocketService(webSocketProxyConfiguration); HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); diff --git a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketHttpServletRequestWrapperTest.java b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketHttpServletRequestWrapperTest.java index b11529bf2f176..48a822272b8bd 100644 --- a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketHttpServletRequestWrapperTest.java +++ b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketHttpServletRequestWrapperTest.java @@ -18,6 +18,7 @@ */ package org.apache.pulsar.websocket; +import lombok.Cleanup; import org.apache.pulsar.common.configuration.PulsarConfigurationLoader; import org.apache.pulsar.websocket.service.WebSocketProxyConfiguration; import org.eclipse.jetty.websocket.servlet.UpgradeHttpServletRequest; @@ -70,6 +71,7 @@ public void mockRequestTest() throws Exception { WebSocketProxyConfiguration.class); String publicKeyPath = "file://" + this.getClass().getClassLoader().getResource("my-public.key").getFile(); config.getProperties().setProperty("tokenPublicKey", publicKeyPath); + @Cleanup WebSocketService service = new WebSocketService(config); service.start();