-
Notifications
You must be signed in to change notification settings - Fork 332
Description
The UsingLatches implementation always prints "All services up and running!", regardless of whether all services have actually started.
The code calls latch.await(2, TimeUnit.SECONDS) but does not check its boolean return value. If await() returns false, it indicates that not all services have completed initialization within the timeout, yet the message "All services up and running!" is still printed.
Expected Behavior:
If await() returns true, then print "All services up and running!".
If await() returns false, print that not all services are up and running
boolean awaitResult = latch.await(2, TimeUnit.SECONDS);
if(awaitResult)
System.out.println("All services up and running!");
else
System.out.println("No all services are up and running! Missing: " + (totalServices - latch.getCount()));