You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/01/19 08:20:50 UTC

[GitHub] nkurihar closed pull request #1085: Fixed some of the warnings in Maven build

nkurihar closed pull request #1085: Fixed some of the warnings in Maven build
URL: https://github.com/apache/incubator-pulsar/pull/1085
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
index 7736c42b3..795d8071a 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
@@ -111,7 +111,7 @@
     private static final Logger LOG = LoggerFactory.getLogger(AdminApiTest.class);
 
     private MockedPulsarService mockPulsarSetup;
-    
+
     private PulsarService otherPulsar;
 
     private PulsarAdmin otheradmin;
@@ -161,7 +161,7 @@ public void cleanup() throws Exception {
     public Object[][] topicNamesProvider() {
         return new Object[][] { { "topic_+&*%{}() \\/$@#^%" }, { "simple-topicName" } };
     }
-    
+
     @DataProvider(name = "topicType")
     public Object[][] topicTypeProvider() {
         return new Object[][] { { DestinationDomain.persistent.value() },
@@ -361,7 +361,7 @@ public void brokers() throws Exception {
         List<String> list = admin.brokers().getActiveBrokers("use");
         Assert.assertNotNull(list);
         Assert.assertEquals(list.size(), 1);
-        
+
         List<String> list2 = otheradmin.brokers().getActiveBrokers("test");
         Assert.assertNotNull(list2);
         Assert.assertEquals(list2.size(), 1);
@@ -393,7 +393,7 @@ public void brokers() throws Exception {
      * 3. update the configuration with new value
      * 4. wait and verify that new value has been updated
      * </pre>
-     * 
+     *
      * @throws Exception
      */
     @Test
@@ -1214,7 +1214,7 @@ public void testDeleteFailedReturnCode() throws Exception {
     @Test
     public void testJacksonWithTypeDifferencies() throws Exception {
         String expectedJson = "{\"adminRoles\":[\"role1\",\"role2\"],\"allowedClusters\":[\"usw\",\"use\"]}";
-        IncompatiblePropertyAdmin r1 = ObjectMapperFactory.getThreadLocal().reader(IncompatiblePropertyAdmin.class)
+        IncompatiblePropertyAdmin r1 = ObjectMapperFactory.getThreadLocal().readerFor(IncompatiblePropertyAdmin.class)
                 .readValue(expectedJson);
         assertEquals(r1.allowedClusters, Sets.newHashSet("use", "usw"));
         assertEquals(r1.someNewIntField, 0);
@@ -1606,7 +1606,7 @@ public void testPersistentTopicExpireMessageOnParitionTopic() throws Exception {
      * This test-case verifies that broker should support both url/uri encoding for topic-name. It calls below api with
      * url-encoded and also uri-encoded topic-name in http request: a. PartitionedMetadataLookup b. TopicLookup c. Topic
      * Stats
-     * 
+     *
      * @param topicName
      * @throws Exception
      */
@@ -1619,7 +1619,7 @@ public void testPulsarAdminForUriAndUrlEncoding(String topicName) throws Excepti
         final int numOfPartitions = 4;
         admin.persistentTopics().createPartitionedTopic(dn1, numOfPartitions);
         // Create a consumer to get stats on this topic
-        Consumer consumer1 = pulsarClient.subscribe(dn1, "my-subscriber-name", new ConsumerConfiguration());
+        pulsarClient.subscribe(dn1, "my-subscriber-name", new ConsumerConfiguration());
 
         PersistentTopicsImpl persistent = (PersistentTopicsImpl) admin.persistentTopics();
         Field field = PersistentTopicsImpl.class.getDeclaredField("persistentTopics");
@@ -1708,14 +1708,14 @@ public void failed(Throwable e) {
     }
 
     static class MockedPulsarService extends MockedPulsarServiceBaseTest {
-        
+
         private ServiceConfiguration conf;
-        
+
         public MockedPulsarService(ServiceConfiguration conf) {
             super();
             this.conf = conf;
         }
-        
+
         @Override
         protected void setup() throws Exception {
             super.conf.setLoadManagerClassName(conf.getLoadManagerClassName());
@@ -1735,7 +1735,7 @@ public PulsarAdmin getAdmin() {
             return admin;
         }
     }
-    
+
     @Test
     public void testDestinationBundleRangeLookup() throws PulsarAdminException, PulsarServerException, Exception {
         admin.clusters().createCluster("usw", new ClusterData());
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
index 1de1f1484..8b34681ac 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
@@ -189,7 +189,7 @@ protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
     }
 
     public static MockZooKeeper createMockZooKeeper() throws Exception {
-        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.sameThreadExecutor());
+        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.newDirectExecutorService());
         List<ACL> dummyAclList = new ArrayList<ACL>(0);
 
         ZkUtils.createFullPathOptimistic(zk, "/ledgers/available/192.168.1.1:" + 5000,
@@ -255,6 +255,6 @@ public static void retryStrategically(Predicate<Void> predicate, int retryCount,
             Thread.sleep(intSleepTime + (intSleepTime * i));
         }
     }
-    
+
     private static final Logger log = LoggerFactory.getLogger(MockedPulsarServiceBaseTest.class);
 }
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
index ebe361cfc..0d14432da 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
@@ -21,7 +21,6 @@
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
@@ -43,7 +42,6 @@
 import org.apache.bookkeeper.test.PortManager;
 import org.apache.pulsar.broker.PulsarService;
 import org.apache.pulsar.broker.ServiceConfiguration;
-import org.apache.pulsar.broker.web.PulsarWebResource;
 import org.apache.pulsar.client.admin.PulsarAdmin;
 import org.apache.pulsar.client.admin.PulsarAdminException.ConflictException;
 import org.apache.pulsar.client.api.Authentication;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/BrokerServiceLookupTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/BrokerServiceLookupTest.java
index c3c239b74..644797b10 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/BrokerServiceLookupTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/BrokerServiceLookupTest.java
@@ -612,6 +612,8 @@ public void testDiscoveryLookupAuthAndAuthSuccess() throws Exception {
         ClientConfiguration clientConfig = new ClientConfiguration();
         // set authentication data
         clientConfig.setAuthentication(new Authentication() {
+            private static final long serialVersionUID = 1L;
+
             @Override
             public void close() throws IOException {
             }
@@ -622,6 +624,7 @@ public String getAuthMethodName() {
             @Override
             public AuthenticationDataProvider getAuthData() throws PulsarClientException {
                 return new AuthenticationDataProvider() {
+                    private static final long serialVersionUID = 1L;
                 };
             }
             @Override
@@ -677,6 +680,8 @@ public void testDiscoveryLookupAuthenticationFailure() throws Exception {
         ClientConfiguration clientConfig = new ClientConfiguration();
         // set authentication data
         clientConfig.setAuthentication(new Authentication() {
+            private static final long serialVersionUID = 1L;
+
             @Override
             public void close() throws IOException {
             }
@@ -687,6 +692,7 @@ public String getAuthMethodName() {
             @Override
             public AuthenticationDataProvider getAuthData() throws PulsarClientException {
                 return new AuthenticationDataProvider() {
+                    private static final long serialVersionUID = 1L;
                 };
             }
             @Override
@@ -727,6 +733,8 @@ public void testDiscoveryLookupAuthorizationFailure() throws Exception {
         ClientConfiguration clientConfig = new ClientConfiguration();
         // set authentication data
         clientConfig.setAuthentication(new Authentication() {
+            private static final long serialVersionUID = 1L;
+
             @Override
             public void close() throws IOException {
             }
@@ -737,6 +745,7 @@ public String getAuthMethodName() {
             @Override
             public AuthenticationDataProvider getAuthData() throws PulsarClientException {
                 return new AuthenticationDataProvider() {
+                    private static final long serialVersionUID = 1L;
                 };
             }
             @Override
@@ -856,13 +865,13 @@ public void testSplitUnloadLookupTest() throws Exception {
         pulsar2.close();
 
     }
-    
+
     /**
-     * 
+     *
      * <pre>
      * When broker-1's Modular-load-manager splits the bundle and update local-policies, broker-2 should get watch of
      * local-policies and update bundleCache so, new lookup can be redirected properly.
-     * 
+     *
      * (1) Start broker-1 and broker-2
      * (2) Make sure broker-2 always assign bundle to broker1
      * (3) Broker-2 receives topic-1 request, creates local-policies and sets the watch
@@ -870,9 +879,9 @@ public void testSplitUnloadLookupTest() throws Exception {
      * (5) Broker-2 will be a leader and trigger Split the bundle for topic-1
      * (6) Broker-2 should get the watch and update bundle cache
      * (7) Make lookup request again to Broker-2 which should succeed.
-     * 
+     *
      * </pre>
-     * 
+     *
      * @throws Exception
      */
     @Test(timeOut = 5000)
@@ -1094,7 +1103,7 @@ public void onThrowable(Throwable t) {
                     log.warn("[{}] Error during HTTP get request: {}", requestUrl, e.getMessage());
                     future.completeExceptionally(new PulsarClientException(e));
                 }
-            }, MoreExecutors.sameThreadExecutor());
+            }, MoreExecutors.directExecutor());
 
         } catch (Exception e) {
             log.warn("[{}] Failed to get authentication data for lookup: {}", path, e.getMessage());
@@ -1115,7 +1124,7 @@ private AsyncHttpClient getHttpClient(String version) {
             @Override
             public boolean keepAlive(Request ahcRequest, HttpRequest request, HttpResponse response) {
                 // Close connection upon a server error or per HTTP spec
-                return (response.getStatus().code() / 100 != 5) && super.keepAlive(ahcRequest, request, response);
+                return (response.status().code() / 100 != 5) && super.keepAlive(ahcRequest, request, response);
             }
         });
         AsyncHttpClientConfig config = confBuilder.build();
diff --git a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
index 1bbeb06dc..85e9f8e58 100644
--- a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
+++ b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
@@ -18,19 +18,20 @@
  */
 package org.apache.pulsar.client.impl.auth;
 
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.security.PrivateKey;
 import java.util.Base64;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
-
 import org.apache.pulsar.client.api.Authentication;
 import org.apache.pulsar.client.api.AuthenticationDataProvider;
 import org.apache.pulsar.client.api.EncodedAuthenticationParameterSupport;
@@ -38,20 +39,19 @@
 import org.apache.pulsar.client.api.PulsarClientException.GettingAuthenticationDataException;
 import org.apache.pulsar.common.util.ObjectMapperFactory;
 
-import java.security.PrivateKey;
-
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.Splitter;
-
-import com.yahoo.athenz.zts.RoleToken;
-import com.yahoo.athenz.zts.ZTSClient;
 import com.yahoo.athenz.auth.ServiceIdentityProvider;
 import com.yahoo.athenz.auth.impl.SimpleServiceIdentityProvider;
 import com.yahoo.athenz.auth.util.Crypto;
+import com.yahoo.athenz.zts.RoleToken;
+import com.yahoo.athenz.zts.ZTSClient;
 
 public class AuthenticationAthenz implements Authentication, EncodedAuthenticationParameterSupport {
 
+    private static final long serialVersionUID = 1L;
+
     private static final String APPLICATION_X_PEM_FILE = "application/x-pem-file";
     private static final String APPLICATION_X_PEM_FILE_BASE64 = "application/x-pem-file;base64";
 
@@ -78,7 +78,7 @@ public String getAuthMethodName() {
     @Override
     synchronized public AuthenticationDataProvider getAuthData() throws PulsarClientException {
         if (cachedRoleTokenIsValid()) {
-            return new AuthenticationDataAthenz(roleToken, getZtsClient().getHeader());
+            return new AuthenticationDataAthenz(roleToken, ZTSClient.getHeader());
         }
         try {
             // the following would set up the API call that requests tokens from the server
@@ -86,7 +86,7 @@ synchronized public AuthenticationDataProvider getAuthData() throws PulsarClient
             RoleToken token = getZtsClient().getRoleToken(providerDomain, null, minValidity, maxValidity, false);
             roleToken = token.getToken();
             cachedRoleTokenTimestamp = System.nanoTime();
-            return new AuthenticationDataAthenz(roleToken, getZtsClient().getHeader());
+            return new AuthenticationDataAthenz(roleToken, ZTSClient.getHeader());
         } catch (Throwable t) {
             throw new GettingAuthenticationDataException(t);
         }
@@ -120,6 +120,7 @@ public void configure(String encodedAuthParamString) {
     }
 
     @Override
+    @Deprecated
     public void configure(Map<String, String> authParams) {
         setAuthParams(authParams);
     }
diff --git a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataAthenz.java b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataAthenz.java
index bde3b289a..3b4f1a2e6 100644
--- a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataAthenz.java
+++ b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataAthenz.java
@@ -27,6 +27,8 @@
 import java.util.Set;
 
 public class AuthenticationDataAthenz implements AuthenticationDataProvider {
+    private static final long serialVersionUID = 1L;
+
     protected String roleToken;
     protected String httpHeaderName;
 
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/api/Authentication.java b/pulsar-client/src/main/java/org/apache/pulsar/client/api/Authentication.java
index 3529d9158..981b9997c 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/api/Authentication.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/api/Authentication.java
@@ -43,9 +43,7 @@
      * Configure the authentication plugins with the supplied parameters
      *
      * @param authParams
-     * @deprecated This method will be deleted on versin 2.0, instead please use configure(String encodedAuthParamString) which is in EncodedAuthenticationParameterSupport for now and will be integrated into this interface.
      */
-    @Deprecated
     void configure(Map<String, String> authParams);
 
     /**
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/api/AuthenticationFactory.java b/pulsar-client/src/main/java/org/apache/pulsar/client/api/AuthenticationFactory.java
index a3051527c..80e5dd0cb 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/api/AuthenticationFactory.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/api/AuthenticationFactory.java
@@ -51,6 +51,7 @@
      * @return instance of the Authentication-Plugin
      * @throws UnsupportedAuthenticationException
      */
+    @SuppressWarnings("deprecation")
     public static final Authentication create(String authPluginClassName, String authParamsString)
             throws UnsupportedAuthenticationException {
         try {
@@ -81,6 +82,7 @@ public static final Authentication create(String authPluginClassName, String aut
      * @return instance of the Authentication-Plugin
      * @throws UnsupportedAuthenticationException
      */
+    @SuppressWarnings("deprecation")
     public static final Authentication create(String authPluginClassName, Map<String, String> authParams)
             throws UnsupportedAuthenticationException {
         try {
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java
index 5373849db..d178c2457 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java
@@ -81,7 +81,7 @@ protected HttpClient(String serviceUrl, Authentication authentication, EventLoop
             @Override
             public boolean keepAlive(Request ahcRequest, HttpRequest request, HttpResponse response) {
                 // Close connection upon a server error or per HTTP spec
-                return (response.getStatus().code() / 100 != 5) && super.keepAlive(ahcRequest, request, response);
+                return (response.status().code() / 100 != 5) && super.keepAlive(ahcRequest, request, response);
             }
         });
 
@@ -161,7 +161,7 @@ public void onThrowable(Throwable t) {
                     log.warn("[{}] Error during HTTP get request: {}", requestUrl, e.getMessage());
                     future.completeExceptionally(new PulsarClientException(e));
                 }
-            }, MoreExecutors.sameThreadExecutor());
+            }, MoreExecutors.directExecutor());
 
         } catch (Exception e) {
             log.warn("[{}] Failed to get authentication data for lookup: {}", path, e.getMessage());
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationTls.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationTls.java
index fa2956e97..1d8f0f7cf 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationTls.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationTls.java
@@ -26,14 +26,16 @@
 import org.apache.pulsar.client.api.PulsarClientException;
 
 /**
- * 
+ *
  * This plugin requires these parameters
- * 
+ *
  * tlsCertFile: A file path for a client certificate. tlsKeyFile: A file path for a client private key.
  *
  */
 public class AuthenticationTls implements Authentication {
 
+    private static final long serialVersionUID = 1L;
+
     private String certFilePath;
     private String keyFilePath;
 
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/stats/Metrics.java b/pulsar-common/src/main/java/org/apache/pulsar/common/stats/Metrics.java
index ce5c89d24..0281da777 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/stats/Metrics.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/stats/Metrics.java
@@ -21,6 +21,8 @@
 import java.util.Collections;
 import java.util.Map;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.google.common.base.Objects;
 import com.google.common.collect.Maps;
@@ -38,7 +40,7 @@
 
     final Map<String, Object> metrics;
 
-    @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
+    @JsonInclude(content=Include.NON_EMPTY)
     final Map<String, String> dimensions;
 
     // hide constructor
diff --git a/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/BaseDiscoveryTestSetup.java b/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/BaseDiscoveryTestSetup.java
index b7caf7be7..540d3b826 100644
--- a/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/BaseDiscoveryTestSetup.java
+++ b/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/BaseDiscoveryTestSetup.java
@@ -46,38 +46,38 @@
     protected MockZooKeeper mockZookKeeper;
     private final String TLS_SERVER_CERT_FILE_PATH = "./src/test/resources/certificate/server.crt";
     private final String TLS_SERVER_KEY_FILE_PATH = "./src/test/resources/certificate/server.key";
-    
+
     protected void setup() throws Exception {
         config = new ServiceConfig();
         config.setServicePort(nextFreePort());
         config.setServicePortTls(nextFreePort());
         config.setBindOnLocalhost(true);
-        
+
         config.setTlsEnabled(true);
         config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
         config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
-        
+
         mockZookKeeper = createMockZooKeeper();
         service = spy(new DiscoveryService(config));
         doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
         service.start();
-        
+
     }
-    
+
     protected void cleanup() throws Exception {
         mockZookKeeper.shutdown();
         service.close();
     }
- 
+
     protected MockZooKeeper createMockZooKeeper() throws Exception {
-        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.sameThreadExecutor());
+        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.newDirectExecutorService());
 
         ZkUtils.createFullPathOptimistic(zk, LOADBALANCE_BROKERS_ROOT,
                 "".getBytes(ZookeeperClientFactoryImpl.ENCODING_SCHEME), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
         return zk;
     }
-    
+
     protected ZooKeeperClientFactory mockZooKeeperClientFactory = new ZooKeeperClientFactory() {
 
         @Override
@@ -87,5 +87,5 @@ protected MockZooKeeper createMockZooKeeper() throws Exception {
             return CompletableFuture.completedFuture(mockZookKeeper);
         }
     };
-    
+
 }
diff --git a/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/web/BaseZKStarterTest.java b/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/web/BaseZKStarterTest.java
index ce66eed5e..381deb6af 100644
--- a/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/web/BaseZKStarterTest.java
+++ b/pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/web/BaseZKStarterTest.java
@@ -50,7 +50,7 @@ protected void close() throws Exception {
      * @throws Exception
      */
     protected MockZooKeeper createMockZooKeeper() throws Exception {
-        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.sameThreadExecutor());
+        MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.newDirectExecutorService());
 
         ZkUtils.createFullPathOptimistic(zk, LOADBALANCE_BROKERS_ROOT,
                 "".getBytes(ZookeeperClientFactoryImpl.ENCODING_SCHEME), ZooDefs.Ids.OPEN_ACL_UNSAFE,
diff --git a/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java b/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
index ffb2f0578..754b65dec 100644
--- a/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
+++ b/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
@@ -19,8 +19,8 @@
 package org.apache.pulsar.zookeeper;
 
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertNull;
@@ -34,19 +34,9 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.bookkeeper.mledger.util.Pair;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
-import org.apache.pulsar.zookeeper.Deserializers;
-import org.apache.pulsar.zookeeper.GlobalZooKeeperCache;
-import org.apache.pulsar.zookeeper.LocalZooKeeperCache;
-import org.apache.pulsar.zookeeper.ZooKeeperCache;
-import org.apache.pulsar.zookeeper.ZooKeeperCacheListener;
-import org.apache.pulsar.zookeeper.ZooKeeperChildrenCache;
-import org.apache.pulsar.zookeeper.ZooKeeperClientFactory;
-import org.apache.pulsar.zookeeper.ZooKeeperDataCache;
 import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.MockZooKeeper;
 import org.apache.zookeeper.WatchedEvent;
@@ -70,7 +60,7 @@
 
     @BeforeMethod
     void setup() throws Exception {
-        zkClient = MockZooKeeper.newInstance(MoreExecutors.sameThreadExecutor());
+        zkClient = MockZooKeeper.newInstance(MoreExecutors.newDirectExecutorService());
     }
 
     @AfterMethod
@@ -124,7 +114,7 @@ public String deserialize(String key, byte[] content) throws Exception {
     void testChildrenCache() throws Exception {
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1, "test");
         ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
-        
+
         zkClient.create("/test", new byte[0], null, null);
 
         ZooKeeperCache zkCacheService = new LocalZooKeeperCache(zkClient, executor, scheduledExecutor);
@@ -181,7 +171,7 @@ void testChildrenCache() throws Exception {
     void testExistsCache() throws Exception {
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1, "test");
         ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
-        
+
         // Check existence after creation of the node
         zkClient.create("/test", new byte[0], null, null);
         Thread.sleep(20);
@@ -202,7 +192,7 @@ void testExistsCache() throws Exception {
     void testInvalidateCache() throws Exception {
         OrderedSafeExecutor executor = new OrderedSafeExecutor(1, "test");
         ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
-        
+
         zkClient.create("/test", new byte[0], null, null);
         zkClient.create("/test/c1", new byte[0], null, null);
         zkClient.create("/test/c2", new byte[0], null, null);
@@ -340,11 +330,11 @@ public String deserialize(String key, byte[] content) throws Exception {
         // Update shouldn't happen after the last check
         assertEquals(notificationCount.get(), 1);
     }
-    
+
     /**
      * Verifies that blocking call on zkCache-callback will not introduce deadlock because zkCache completes
      * future-result with different thread than zookeeper-client thread.
-     * 
+     *
      * @throws Exception
      */
     @Test(timeOut = 2000)
@@ -387,14 +377,14 @@ public String deserialize(String key, byte[] content) throws Exception {
         zkExecutor.shutdown();
         scheduledExecutor.shutdown();
     }
-    
+
     /**
      * <pre>
-     * Verifies that if {@link ZooKeeperCache} fails to fetch data into the cache then 
+     * Verifies that if {@link ZooKeeperCache} fails to fetch data into the cache then
      * (1) it invalidates failed future so, next time it helps to get fresh data from zk
      * (2) handles zk.getData() unexpected exception if zkSession is lost
      * </pre>
-     * 
+     *
      * @throws Exception
      */
     @Test


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services