Ensure Pruning Service shuts down
This closes #49
Signed-off-by: anew <anew@apache.org>
diff --git a/tephra-core/src/main/java/org/apache/tephra/distributed/TransactionService.java b/tephra-core/src/main/java/org/apache/tephra/distributed/TransactionService.java
index d4a0f87..f95e5b3 100644
--- a/tephra-core/src/main/java/org/apache/tephra/distributed/TransactionService.java
+++ b/tephra-core/src/main/java/org/apache/tephra/distributed/TransactionService.java
@@ -121,15 +121,15 @@
@Override
public void follower() {
ListenableFuture<State> stopFuture = null;
+ if (pruningService != null && pruningService.isRunning()) {
+ // Wait for pruning service to stop after un-registering from discovery
+ stopFuture = pruningService.stop();
+ }
// First stop the transaction server as un-registering from discovery can block sometimes.
// That can lead to multiple transaction servers being active at the same time.
if (server != null && server.isRunning()) {
server.stopAndWait();
}
- if (pruningService != null && pruningService.isRunning()) {
- // Wait for pruning service to stop after un-registering from discovery
- stopFuture = pruningService.stop();
- }
undoRegister();
if (stopFuture != null) {