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/03/22 16:07:57 UTC

[GitHub] merlimat closed pull request #1420: Null checks in MockedPulsarServiceBaseTest

merlimat closed pull request #1420: Null checks in MockedPulsarServiceBaseTest
URL: https://github.com/apache/incubator-pulsar/pull/1420
 
 
   

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/auth/MockedPulsarServiceBaseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
index 02055ac5b..66b6f6a5e 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
@@ -136,15 +136,26 @@ protected final void init() throws Exception {
 
     protected final void internalCleanup() throws Exception {
         try {
-            admin.close();
-            // There are some test cases where pulsarClient is not initialized.
+            // if init fails, some of these could be null, and if so would throw
+            // an NPE in shutdown, obscuring the real error
+            if (admin != null) {
+                admin.close();
+            }
             if (pulsarClient != null) {
                 pulsarClient.close();
             }
-            pulsar.close();
-            mockBookKeeper.reallyShutdow();
-            mockZookKeeper.shutdown();
-            sameThreadOrderedSafeExecutor.shutdown();
+            if (pulsar != null) {
+                pulsar.close();
+            }
+            if (mockBookKeeper != null) {
+                mockBookKeeper.reallyShutdow();
+            }
+            if (mockZookKeeper != null) {
+                mockZookKeeper.shutdown();
+            }
+            if (sameThreadOrderedSafeExecutor != null) {
+                sameThreadOrderedSafeExecutor.shutdown();
+            }
         } catch (Exception e) {
             log.warn("Failed to clean up mocked pulsar service:", e);
             throw e;


 

----------------------------------------------------------------
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