@Test void testIncrementThrowsShutdownInProgressExceptionIfShuttingDown() { testSubject.initiateShutdown(); assertThrows(ShutdownInProgressException.class, testSubject::registerActivity); }
public CompletableFuture<Void> initiateShutdown() { CompletableFuture<Void> newLatch = new CompletableFuture<>(); CompletableFuture<Void> existingLatch = latch.getAndUpdate(previous -> previous == null ? newLatch : previous); if (existingLatch == null) { if (operationCounter.get() == 0) { newLatch.complete(null); } return newLatch; } return existingLatch; }
ShutdownLatch { public CompletableFuture<Void> initiateShutdown() { CompletableFuture<Void> newLatch = new CompletableFuture<>(); CompletableFuture<Void> existingLatch = latch.getAndUpdate(previous -> previous == null ? newLatch : previous); if (existingLatch == null) { if (operationCounter.get() == 0) { newLatch.complete(null); } return newLatch; } return existingLatch; } }
ShutdownLatch { public CompletableFuture<Void> initiateShutdown() { CompletableFuture<Void> newLatch = new CompletableFuture<>(); CompletableFuture<Void> existingLatch = latch.getAndUpdate(previous -> previous == null ? newLatch : previous); if (existingLatch == null) { if (operationCounter.get() == 0) { newLatch.complete(null); } return newLatch; } return existingLatch; }  }
ShutdownLatch { public CompletableFuture<Void> initiateShutdown() { CompletableFuture<Void> newLatch = new CompletableFuture<>(); CompletableFuture<Void> existingLatch = latch.getAndUpdate(previous -> previous == null ? newLatch : previous); if (existingLatch == null) { if (operationCounter.get() == 0) { newLatch.complete(null); } return newLatch; } return existingLatch; }  void initialize(); ActivityHandle registerActivity(); void ifShuttingDown(String exceptionMessage); void ifShuttingDown(Supplier<RuntimeException> exceptionSupplier); boolean isShuttingDown(); CompletableFuture<Void> initiateShutdown(); }
ShutdownLatch { public CompletableFuture<Void> initiateShutdown() { CompletableFuture<Void> newLatch = new CompletableFuture<>(); CompletableFuture<Void> existingLatch = latch.getAndUpdate(previous -> previous == null ? newLatch : previous); if (existingLatch == null) { if (operationCounter.get() == 0) { newLatch.complete(null); } return newLatch; } return existingLatch; }  void initialize(); ActivityHandle registerActivity(); void ifShuttingDown(String exceptionMessage); void ifShuttingDown(Supplier<RuntimeException> exceptionSupplier); boolean isShuttingDown(); CompletableFuture<Void> initiateShutdown();  }