Open
Description
openedon Mar 26, 2020
Consider this code nippet:
public class ServiceTest {
private static class ServiceA extends AbstractIdleService {
@Override
protected void startUp() throws Exception {
System.out.println("Starting A");
if (true) {
throw new RuntimeException("Sorry…");
}
System.out.println("Finished starting A");
}
@Override
protected void shutDown() throws Exception {
System.out.println("Stopping A");
}
}
public static void main(String[] args) throws Exception {
final ServiceA serviceA= new ServiceA();
serviceA.startAsync();
// serviceA.awaitRunning();
Thread.sleep(1000);
}
}
Unless I activate the serviceA.awaitRunning()
(or implement an explicit Listener) the exception thrown when starting up just vanishes. It doesn't even get logged or printed to stdout.
I don't consider that a sane default behaviour as it makes it harder to spot actual problems in the codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment