Repository: incubator-tephra
Updated Branches:
  refs/heads/master 7cfe06125 -> 827a70c68


TEPHRA-239 Fix NPE by waiting for the service to startup

This closes #46 from GitHub.

Signed-off-by: Gokul Gunasekaran <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-tephra/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tephra/commit/827a70c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tephra/tree/827a70c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tephra/diff/827a70c6

Branch: refs/heads/master
Commit: 827a70c689664e85c6f37ee0bdce59fb3bbc80d9
Parents: 7cfe061
Author: Gokul Gunasekaran <[email protected]>
Authored: Thu Aug 17 10:38:21 2017 -0700
Committer: Gokul Gunasekaran <[email protected]>
Committed: Mon Sep 11 11:19:24 2017 -0700

----------------------------------------------------------------------
 .../apache/tephra/coprocessor/ReferenceCountedSupplier.java | 2 +-
 .../apache/tephra/coprocessor/TransactionStateCache.java    | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/827a70c6/tephra-core/src/main/java/org/apache/tephra/coprocessor/ReferenceCountedSupplier.java
----------------------------------------------------------------------
diff --git 
a/tephra-core/src/main/java/org/apache/tephra/coprocessor/ReferenceCountedSupplier.java
 
b/tephra-core/src/main/java/org/apache/tephra/coprocessor/ReferenceCountedSupplier.java
index a0fa7ad..c929d29 100644
--- 
a/tephra-core/src/main/java/org/apache/tephra/coprocessor/ReferenceCountedSupplier.java
+++ 
b/tephra-core/src/main/java/org/apache/tephra/coprocessor/ReferenceCountedSupplier.java
@@ -54,7 +54,7 @@ public class ReferenceCountedSupplier<T extends Service> {
         // Instance has not been instantiated
         T serviceInstance = instanceSupplier.get();
         instance.set(serviceInstance);
-        serviceInstance.start();
+        serviceInstance.startAndWait();
       }
       int newCount = refCount.incrementAndGet();
       if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/827a70c6/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
----------------------------------------------------------------------
diff --git 
a/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
 
b/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
index 5869685..553d3ce 100644
--- 
a/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
+++ 
b/tephra-core/src/main/java/org/apache/tephra/coprocessor/TransactionStateCache.java
@@ -81,8 +81,13 @@ public class TransactionStateCache extends 
AbstractIdleService implements Config
 
   @Override
   protected void shutDown() throws Exception {
-    this.refreshService.interrupt();
-    this.storage.stop();
+    if (refreshService != null) {
+      refreshService.interrupt();
+    }
+
+    if (storage != null) {
+      storage.stop();
+    }
   }
 
   /**

Reply via email to