Keep startup errors

This commit is contained in:
2026-03-13 14:18:34 -06:00
parent 462e37a443
commit 1e381d59c6

View File

@@ -25,6 +25,7 @@ public class DevStackApplication {
CountDownLatch shutdownLatch = new CountDownLatch(1); CountDownLatch shutdownLatch = new CountDownLatch(1);
ScheduledExecutorService scheduler = null; ScheduledExecutorService scheduler = null;
AtomicBoolean shuttingDown = new AtomicBoolean(false); AtomicBoolean shuttingDown = new AtomicBoolean(false);
RuntimeException startupFailure = null;
try { try {
validateJavaVersion(); validateJavaVersion();
@@ -42,6 +43,7 @@ public class DevStackApplication {
scheduler = startDatabaseWatch(docker, context, shuttingDown); scheduler = startDatabaseWatch(docker, context, shuttingDown);
shutdownLatch.await(); shutdownLatch.await();
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
startupFailure = ex;
throw new IllegalStateException(describeStartupFailure(ex), ex); throw new IllegalStateException(describeStartupFailure(ex), ex);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
@@ -54,7 +56,15 @@ public class DevStackApplication {
context.close(); context.close();
} }
if (!shuttingDown.get()) { if (!shuttingDown.get()) {
docker.stopDatabase(); try {
docker.stopDatabase();
} catch (RuntimeException stopFailure) {
if (startupFailure != null) {
System.err.println(stopFailure.getMessage());
} else {
throw stopFailure;
}
}
} }
} }
} }