Skip to content

Commit

Permalink
PulsarAdmin: Fix last exit code storage (#12581)
Browse files Browse the repository at this point in the history
(cherry picked from commit d357cec)
  • Loading branch information
thomasleplus authored and codelipenghui committed Nov 7, 2021
1 parent 52764ce commit 4e4f49d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public static void main(String[] args) throws Exception {
}

private static void exit(int code) {
lastExitCode = lastExitCode;
lastExitCode = code;
if (allowSystemExit) {
// we are using halt and not System.exit, we do not mind about shutdown hooks
// they are only slowing down the tool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public class TestRunMain {
public void runMainNoArguments() throws Exception {
PulsarAdminTool.setAllowSystemExit(false);
PulsarAdminTool.main(new String[0]);
assertEquals(PulsarAdminTool.getLastExitCode(), 0);
assertEquals(PulsarAdminTool.getLastExitCode(), 1);
}

@Test
public void runMainDummyConfigFile() throws Exception {
PulsarAdminTool.setAllowSystemExit(false);
Path dummyEmptyFile = Files.createTempFile("test", ".conf");
PulsarAdminTool.main(new String[] {dummyEmptyFile.toAbsolutePath().toString()});
assertEquals(PulsarAdminTool.getLastExitCode(), 0);
assertEquals(PulsarAdminTool.getLastExitCode(), 1);
}
}

0 comments on commit 4e4f49d

Please sign in to comment.