Skip to content

Commit

Permalink
Close the delayed log handler if exception
Browse files Browse the repository at this point in the history
If the handler has not been activated, we flush the content of the log
when we have an exception. Otherwise, the user is missing important
information.

This is especially important when a resource does not start properly.
  • Loading branch information
gsmet committed Oct 15, 2021
1 parent 1f3d58f commit 5d19217
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
import org.opentest4j.TestAbortedException;

import io.quarkus.bootstrap.logging.InitialConfigurator;
import io.quarkus.runtime.test.TestHttpEndpointProvider;
import io.quarkus.test.common.ArtifactLauncher;
import io.quarkus.test.common.DevServicesContext;
Expand Down Expand Up @@ -194,6 +195,9 @@ public void close() throws Throwable {

return state;
} catch (Throwable e) {
if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) {
InitialConfigurator.DELAYED_HANDLER.close();
}

try {
if (testResourceManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.jupiter.api.extension.ParameterResolver;

import io.quarkus.bootstrap.app.StartupAction;
import io.quarkus.bootstrap.logging.InitialConfigurator;
import io.quarkus.deployment.dev.testing.LogCapturingOutputFilter;
import io.quarkus.dev.console.QuarkusConsole;
import io.quarkus.dev.testing.TracingHandler;
Expand Down Expand Up @@ -157,6 +158,9 @@ private int doJavaStart(ExtensionContext context, Class<? extends QuarkusTestPro

return startupAction.runMainClassBlocking(arguments);
} catch (Throwable e) {
if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) {
InitialConfigurator.DELAYED_HANDLER.close();
}

try {
if (testResourceManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import io.quarkus.bootstrap.app.StartupAction;
import io.quarkus.bootstrap.classloading.ClassPathElement;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.bootstrap.logging.InitialConfigurator;
import io.quarkus.builder.BuildChainBuilder;
import io.quarkus.builder.BuildContext;
import io.quarkus.builder.BuildStep;
Expand Down Expand Up @@ -288,6 +289,9 @@ public void close() throws IOException {
ExtensionState state = new ExtensionState(testResourceManager, shutdownTask);
return state;
} catch (Throwable e) {
if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) {
InitialConfigurator.DELAYED_HANDLER.close();
}

try {
if (testResourceManager != null) {
Expand Down

0 comments on commit 5d19217

Please sign in to comment.