@Test public void removesRequestWhenFailedOrTimesOut() { AsyncResult<Void> result1 = new AsyncResult<>(); AsyncResult<Void> result2 = new AsyncResult<>(); awaitedLocks.getExistingOrAwait(REQUEST_1, () -> result1); awaitedLocks.getExistingOrAwait(REQUEST_1, () -> result2); result1.fail(new RuntimeException("test")); result2.timeout(); assertRequestsWereRemoved(REQUEST_1, REQUEST_2); }
public AsyncResult<Void> getExistingOrAwait( UUID requestId, Supplier<AsyncResult<Void>> lockAwaiter) { AsyncResult<Void> result = requestsById.computeIfAbsent( requestId, ignored -> lockAwaiter.get()); registerCompletionHandler(requestId, result); return result; }
AwaitedLocksCollection { public AsyncResult<Void> getExistingOrAwait( UUID requestId, Supplier<AsyncResult<Void>> lockAwaiter) { AsyncResult<Void> result = requestsById.computeIfAbsent( requestId, ignored -> lockAwaiter.get()); registerCompletionHandler(requestId, result); return result; } }
AwaitedLocksCollection { public AsyncResult<Void> getExistingOrAwait( UUID requestId, Supplier<AsyncResult<Void>> lockAwaiter) { AsyncResult<Void> result = requestsById.computeIfAbsent( requestId, ignored -> lockAwaiter.get()); registerCompletionHandler(requestId, result); return result; }  }
AwaitedLocksCollection { public AsyncResult<Void> getExistingOrAwait( UUID requestId, Supplier<AsyncResult<Void>> lockAwaiter) { AsyncResult<Void> result = requestsById.computeIfAbsent( requestId, ignored -> lockAwaiter.get()); registerCompletionHandler(requestId, result); return result; }  AsyncResult<Void> getExistingOrAwait(
            UUID requestId,
            Supplier<AsyncResult<Void>> lockAwaiter); }
AwaitedLocksCollection { public AsyncResult<Void> getExistingOrAwait( UUID requestId, Supplier<AsyncResult<Void>> lockAwaiter) { AsyncResult<Void> result = requestsById.computeIfAbsent( requestId, ignored -> lockAwaiter.get()); registerCompletionHandler(requestId, result); return result; }  AsyncResult<Void> getExistingOrAwait(
            UUID requestId,
            Supplier<AsyncResult<Void>> lockAwaiter);  }