1. Lock.lockAsync does not throw DatabaseException.
2. Changed thread pool in LockManager to be non-static.
Change-Id: Ie4e9acd497bacb9d6d812836a930ee79f92cf555
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
index 81195b4..629c50c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLock.java
@@ -66,10 +66,16 @@
@Override
public CompletableFuture<Void> lockAsync(int leaseDurationMillis) {
- if (isLocked() || tryLock(leaseDurationMillis)) {
- return CompletableFuture.<Void>completedFuture(null);
+ try {
+ if (isLocked() || tryLock(leaseDurationMillis)) {
+ return CompletableFuture.<Void>completedFuture(null);
+ }
+ return lockManager.lockIfAvailable(this, leaseDurationMillis);
+ } catch (DatabaseException e) {
+ CompletableFuture<Void> lockFuture = new CompletableFuture<>();
+ lockFuture.completeExceptionally(e);
+ return lockFuture;
}
- return lockManager.lockIfAvailable(this, leaseDurationMillis);
}
@Override