Skip to content

Commit

Permalink
Exit with code 137 when we get an OutOfMemoryError (broadinstitute#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
droazen authored Apr 4, 2023
1 parent bbb8be6 commit 497725a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/broadinstitute/hellbender/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public class Main {
* exit value when any unrecoverable exception other than {@link UserException} occurs
*/
private static final int ANY_OTHER_EXCEPTION_EXIT_VALUE = 3;

/**
* exit value when an out of memory error occurs
*/
private static final int OUT_OF_MEMORY_EXIT_VALUE = 137;

private static final String STACK_TRACE_ON_USER_EXCEPTION_PROPERTY = "GATK_STACKTRACE_ON_USER_EXCEPTION";

/**
Expand Down Expand Up @@ -219,6 +225,9 @@ protected final void mainEntry(final String[] args) {
} catch (final StorageException e) {
handleStorageException(e);
System.exit(ANY_OTHER_EXCEPTION_EXIT_VALUE);
} catch (final OutOfMemoryError e) {
handleNonUserException(e);
System.exit(OUT_OF_MEMORY_EXIT_VALUE);
} catch (final Exception e){
handleNonUserException(e);
System.exit(ANY_OTHER_EXCEPTION_EXIT_VALUE);
Expand Down Expand Up @@ -266,6 +275,14 @@ protected void handleNonUserException(final Exception exception) {
exception.printStackTrace();
}

/**
* Handle any Error that does not come from the user. Default implementation prints the stack trace.
* @param error the Error to handle (never an {@link UserException}).
*/
protected void handleNonUserException(final Error error) {
error.printStackTrace();
}

/**
* Handle any exception that does not come from the user. Default implementation prints the stack trace.
* @param exception the exception to handle (never an {@link UserException}).
Expand Down

0 comments on commit 497725a

Please sign in to comment.