Skip to content

Commit

Permalink
Revert "Fix io.smallrye.config.ConfigValidationException not being ha…
Browse files Browse the repository at this point in the history
…ndled properly at Quarkus startup"

This reverts commit 017e57b.
  • Loading branch information
radcortez committed Jun 13, 2024
1 parent 3c6e8f9 commit 26c5033
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
import io.quarkus.deployment.builditem.MainBytecodeRecorderBuildItem;
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem;
import io.quarkus.gizmo.CatchBlockCreator;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.TryBlock;
import io.quarkus.runtime.StartupContext;
import io.quarkus.runtime.StartupTask;
import io.quarkus.runtime.configuration.ConfigurationException;

public class RuntimeConfigSetupBuildStep {
private static final String RUNTIME_CONFIG_STARTUP_TASK_CLASS_NAME = "io.quarkus.deployment.steps.RuntimeConfigSetup";
Expand All @@ -40,17 +37,11 @@ void setupRuntimeConfig(
.interfaces(StartupTask.class).build()) {

try (MethodCreator method = clazz.getMethodCreator("deploy", void.class, StartupContext.class)) {
TryBlock tryBlock = method.tryBlock();
tryBlock.invokeVirtualMethod(
ofMethod(StartupContext.class, "setCurrentBuildStepName", void.class, String.class),
method.invokeVirtualMethod(ofMethod(StartupContext.class, "setCurrentBuildStepName", void.class, String.class),
method.getMethodParam(0), method.load("RuntimeConfigSetupBuildStep.setupRuntimeConfig"));

tryBlock.invokeStaticMethod(C_CREATE_RUN_TIME_CONFIG);
tryBlock.returnValue(null);

CatchBlockCreator cb = tryBlock.addCatch(RuntimeException.class);
cb.throwException(ConfigurationException.class, "Failed to read configuration properties",
cb.getCaughtException());
method.invokeStaticMethod(C_CREATE_RUN_TIME_CONFIG);
method.returnValue(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ public static void run(Application application, Class<? extends QuarkusApplicati
}
applicationLogger.warn("You can try to kill it with 'kill -9 <pid>'.");
}
} else if (ExceptionUtil.isAnyCauseInstanceOf(e, ConfigurationException.class)) {
} else if (rootCause instanceof ConfigurationException) {
System.err.println(rootCause.getMessage());
e.printStackTrace();
} else if (rootCause instanceof PreventFurtherStepsException
&& !StringUtil.isNullOrEmpty(rootCause.getMessage())) {
System.err.println(rootCause.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ public static Throwable getRootCause(Throwable exception) {
return chain.isEmpty() ? null : chain.get(chain.size() - 1);
}

public static <T> boolean isAnyCauseInstanceOf(Throwable exception, Class<T> classToCheck) {
Throwable curr = exception;
do {
if (classToCheck.isInstance(curr)) {
return true;
}
curr = curr.getCause();
} while (curr != null);
return false;
}

/**
* Creates and returns a new {@link Throwable} which has the following characteristics:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import org.junit.jupiter.api.Test;

import io.quarkus.runtime.configuration.ConfigurationException;

/**
*
*/
Expand Down Expand Up @@ -61,11 +59,6 @@ public void testGetRootCause() {
assertEquals(NullPointerException.class, ExceptionUtil.getRootCause(new NullPointerException()).getClass());
}

@Test
public void testIsAnyCauseInstanceOf() {
assertTrue(ExceptionUtil.isAnyCauseInstanceOf(generateConfigurationException(), ConfigurationException.class));
}

private Throwable generateException() {
try {
try {
Expand All @@ -86,26 +79,4 @@ private Throwable generateException() {
}
throw new RuntimeException("Should not reach here");
}

private Throwable generateConfigurationException() {
try {
try {
Integer.parseInt("23.23232");
} catch (NumberFormatException nfe) {
throw new ConfigurationException("Incorrect param", nfe);
}
} catch (ConfigurationException ce) {
try {
throw new IOException("Request processing failed", ce);
} catch (IOException e) {
try {
throw new IOError(e);
} catch (IOError ie) {
return new RuntimeException("Unexpected exception", ie);
}
}
}
throw new RuntimeException("Should not reach here");
}

}

0 comments on commit 26c5033

Please sign in to comment.