Skip to content

Commit

Permalink
wrap main() so that exit value can be returned
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Jan 2, 2025
1 parent 2b9f957 commit b89417b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ public static Indexer getInstance() {
*
* @param argv argument vector
*/
@SuppressWarnings("PMD.UseStringBufferForStringAppends")
public static void main(String[] argv) {
System.exit(runMain(argv));
}

@SuppressWarnings("PMD.UseStringBufferForStringAppends")
public static int runMain(String[] argv) {
Statistics stats = new Statistics(); //this won't count JVM creation though

Executor.registerErrorHandler();
Expand Down Expand Up @@ -471,9 +475,7 @@ public static void main(String[] argv) {
LOGGER.log(Level.INFO, "Indexer finished with success");
}

if (exitCode != 0) {
System.exit(exitCode);
}
return exitCode;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2019, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.index;
Expand Down Expand Up @@ -77,7 +77,7 @@ void testMainWithH() {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
String[] argv = {"-S", "-H", "-s", repository.getSourceRoot(),
"-d", repository.getDataRoot(), "-v", "-c", env.getCtags()};
Indexer.main(argv);
Indexer.runMain(argv);
checkNumberOfThreads();
}

Expand All @@ -90,7 +90,7 @@ void testMainWithoutH() {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
String[] argv = {"-S", "-P", "-s", repository.getSourceRoot(),
"-d", repository.getDataRoot(), "-v", "-c", env.getCtags()};
Indexer.main(argv);
Indexer.runMain(argv);
checkNumberOfThreads();
}
}

0 comments on commit b89417b

Please sign in to comment.