Skip to content

Commit

Permalink
CADC-12563 cleanup PackageRunner exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jburke-cadc committed Jan 19, 2024
1 parent 03646f4 commit 1d206eb
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ private void doIt() {
PackageWriter writer = null;
try {
ep = jobUpdater.setPhase(job.getID(), getInitialPhase(), ExecutionPhase.EXECUTING, new Date());

if (!ExecutionPhase.EXECUTING.equals(ep)) {
ep = jobUpdater.getPhase(job.getID());
log.debug(String.format("%s: %s -> EXECUTING [FAILED] -- DONE", job.getID(), getInitialPhase()));
Expand Down Expand Up @@ -208,20 +207,12 @@ private void doIt() {
log.debug(job.getID() + ": EXECUTING -> COMPLETED [OK]");

} catch (Throwable t) {
if (ThrowableUtil.isACause(t, InterruptedException.class)) {
try {
ep = jobUpdater.setPhase(job.getID(), getInitialPhase(), ExecutionPhase.EXECUTING, new Date());

if (!ExecutionPhase.ABORTED.equals(ep)) {
return; // clean exit of aborted job
}

} catch (Exception ex2) {
log.error("failed to check job phase after InterruptedException", ex2);

}
try {
ep = jobUpdater.setPhase(job.getID(), job.getExecutionPhase(), ExecutionPhase.ERROR, new Date());
} catch (Exception ex) {
log.error("failed to update job phase to ERROR after exception", ex);
}
sendError(t, 500);
sendError(t, t.getMessage(), 500);
} finally {
// Finalize and close writer instance
if (writer != null) {
Expand Down

0 comments on commit 1d206eb

Please sign in to comment.