Index: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java =================================================================== --- oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (Revision 1854536) +++ oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (Arbeitskopie) @@ -248,6 +248,11 @@ private final AtomicBoolean isDisposed = new AtomicBoolean(); /** + * Whether the lease update thread is disposed. + */ + private final AtomicBoolean isLeaseUpdateDisposed = new AtomicBoolean(); + + /** * The cluster instance info. */ @NotNull @@ -557,7 +562,7 @@ clusterNodeInfo.setLeaseFailureHandler(builder.getLeaseFailureHandler()); } String threadNamePostfix = "(" + clusterId + ")"; - leaseUpdateThread = new Thread(new BackgroundLeaseUpdate(this, isDisposed), + leaseUpdateThread = new Thread(new BackgroundLeaseUpdate(this, isLeaseUpdateDisposed), "DocumentNodeStore lease update thread " + threadNamePostfix); leaseUpdateThread.setDaemon(true); if (!readOnlyMode) { @@ -777,7 +782,7 @@ } } - Utils.joinQuietly(clusterUpdateThread, leaseUpdateThread); + Utils.joinQuietly(clusterUpdateThread); // now mark this cluster node as inactive by disposing the // clusterNodeInfo, but only if final background operations @@ -785,6 +790,10 @@ if (ex == null) { clusterNodeInfo.dispose(); } + + isLeaseUpdateDisposed.set(true); + Utils.joinQuietly(leaseUpdateThread); + store.dispose(); if (blobStore instanceof Closeable) {