Make sure the UserConsentNavigator is always closed by ExecutionEngine
@@ -84,6 +84,7 @@ public class ExecutionEngine {
* @throws ThreadTerminateException Thrown in case the GUI has been closed externally (interrupted).
*/
public ResultStatus process() throws ThreadTerminateException {
+ try {
StepResult next = navigator.next(); // get first step
// loop over steps. break inside loop
while (true) {
@@ -91,10 +92,8 @@ public class ExecutionEngine {
LOG.debug("Step {} finished with result {}.", next.getStepID(), result);
// close dialog on cancel and interrupt
if (result == ResultStatus.INTERRUPTED || Thread.currentThread().isInterrupted()) {
- navigator.close();
throw new ThreadTerminateException("GUI has been interrupted.");
} else if (result == ResultStatus.CANCEL) {
- navigator.close();
return result;
}
@@ -132,7 +131,6 @@ public class ExecutionEngine {
if (navigator.hasNext()) {
next = navigator.replaceNext(replaceStep);
} else {
- navigator.close();
return convertStatus(StepActionResultStatus.NEXT);
}
break;
@@ -157,7 +155,6 @@ public class ExecutionEngine {
LOG.debug("Step Action {} finished with result {}.", action.getStepID(), actionResult.getStatus());
} catch (CancellationException ex) {
LOG.info("StepAction was canceled.", ex);
- navigator.close();
return ResultStatus.CANCEL;
} catch (InterruptedException ex) {
LOG.info("StepAction was interrupted.", ex);
@@ -169,20 +166,17 @@ public class ExecutionEngine {
InvocationTargetExceptionUnchecked iex = (InvocationTargetExceptionUnchecked) ex.getCause();
if (iex.getCause() instanceof ThreadTerminateException) {
LOG.info("StepAction was interrupted.", ex);
- navigator.close();
throw new ThreadTerminateException("GUI has been interrupted.");
}
}
// all other types
LOG.error("StepAction failed with error.", ex.getCause());
- navigator.close();
return ResultStatus.CANCEL;
}
// break out if cancel was returned
if (actionResult.getStatus() == StepActionResultStatus.CANCEL) {
LOG.info("StepAction was canceled.");
- navigator.close();
return ResultStatus.CANCEL;
}
@@ -198,7 +192,6 @@ public class ExecutionEngine {
if (navigator.hasNext()) {
next = navigator.replaceNext(actionReplace);
} else {
- navigator.close();
return convertStatus(StepActionResultStatus.NEXT);
}
break;
@@ -219,7 +212,6 @@ public class ExecutionEngine {
if (navigator.hasNext()) {
next = navigator.next();
} else {
- navigator.close();
return convertStatus(StepActionResultStatus.NEXT);
}
break;
@@ -233,6 +225,10 @@ public class ExecutionEngine {
}
}
}
+ } finally {
+ LOG.debug("Closing UserConsentNavigator.");
+ navigator.close();
+ }
}
/**
