forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
QuarkusMainLauncher
not returning exit code
`QuarkusMainLauncher` always returns `0`, because `currentApplication` is set to `null` in `io.quarkus.runtime.ApplicationLifecycleManager#run(io.quarkus.runtime.Application, java.lang.Class<? extends io.quarkus.runtime.QuarkusApplication>, java.util.function.BiConsumer<java.lang.Integer,java.lang.Throwable>, java.lang.String...)`. This change introduces a new callback to `ApplicationLifecycleManager` used by `StartupActionImpl` to know whether the application was actually started or not. (cherry picked from commit 8e7c255)
- Loading branch information
Showing
7 changed files
with
126 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
integration-tests/picocli-native/src/main/java/io/quarkus/it/picocli/ExitCodeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkus.it.picocli; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "exitcode", versionProvider = DynamicVersionProvider.class) | ||
public class ExitCodeCommand implements Callable<Integer> { | ||
|
||
@CommandLine.Option(names = "--code") | ||
int exitCode; | ||
|
||
@Override | ||
public Integer call() { | ||
return exitCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
integration-tests/picocli/src/main/java/io/quarkus/it/picocli/ExitCodeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkus.it.picocli; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "exitcode") | ||
public class ExitCodeCommand implements Callable<Integer> { | ||
|
||
@CommandLine.Option(names = "--code") | ||
int exitCode; | ||
|
||
@Override | ||
public Integer call() { | ||
return exitCode; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
integration-tests/picocli/src/test/java/io/quarkus/it/picocli/TestExitCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.it.picocli; | ||
|
||
import static io.quarkus.it.picocli.TestUtils.createConfig; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class TestExitCode { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = createConfig("hello-app", ExitCodeCommand.class) | ||
.setCommandLineParameters("--code", "42"); | ||
|
||
@Test | ||
public void simpleTest() { | ||
assertThat(config.getExitCode()).isEqualTo(42); | ||
} | ||
} |