From 4895e62bbefa3e6634c0bdcab1cda2545cae88dd Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 1 Oct 2018 11:09:43 +0100 Subject: [PATCH] Report stacktraces on Shamrock boot error --- .../jboss/shamrock/junit/ShamrockTest.java | 2 +- .../runtime/UndertowDeploymentTemplate.java | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test-framework/junit/src/main/java/org/jboss/shamrock/junit/ShamrockTest.java b/test-framework/junit/src/main/java/org/jboss/shamrock/junit/ShamrockTest.java index bb29d49e3cf24..b4d350cc2cd12 100644 --- a/test-framework/junit/src/main/java/org/jboss/shamrock/junit/ShamrockTest.java +++ b/test-framework/junit/src/main/java/org/jboss/shamrock/junit/ShamrockTest.java @@ -71,7 +71,7 @@ public void testStarted(Description description) { runtimeRunner.run(); } catch (RuntimeException e) { failed = true; - throw e; + throw new RuntimeException("Failed to boot Shamrock during @ShamrockTest runner!", e); } } } diff --git a/undertow/runtime/src/main/java/org/jboss/shamrock/undertow/runtime/UndertowDeploymentTemplate.java b/undertow/runtime/src/main/java/org/jboss/shamrock/undertow/runtime/UndertowDeploymentTemplate.java index 14d6f787e0914..ad42757e607c0 100644 --- a/undertow/runtime/src/main/java/org/jboss/shamrock/undertow/runtime/UndertowDeploymentTemplate.java +++ b/undertow/runtime/src/main/java/org/jboss/shamrock/undertow/runtime/UndertowDeploymentTemplate.java @@ -126,18 +126,23 @@ public void addServletContextParameter(@ContextObject("deploymentInfo") Deployme public void startUndertow(StartupContext startupContext, @ContextObject("servletHandler") HttpHandler handler, String port) throws ServletException { if (undertow == null) { - log.log(Level.INFO, "Starting Undertow on port " + port); - undertow = Undertow.builder() - .addHttpListener(Integer.parseInt(port), "localhost") - .setHandler(new CanonicalPathHandler(ROOT_HANDLER)) - .build(); - undertow.start(); + try { + log.log(Level.INFO, "Starting Undertow on port " + port); + undertow = Undertow.builder() + .addHttpListener(Integer.parseInt(port), "localhost") + .setHandler(new CanonicalPathHandler(ROOT_HANDLER)) + .build(); + undertow.start(); + } + catch (Exception e) { + log.log(Level.SEVERE, "Failed to start Undertow", e); + } } currentRoot = handler; // startupContext.addCloseable(new Closeable() { // @Override // public void close() throws IOException { -// val.stop(); +// undertow.stop(); // } // }); }