Commit cf71e535 authored by Tobias Wich's avatar Tobias Wich
Browse files

Merge branch 'remove_ui_deadlock'

parents e64cf787 bd3e7f71
......@@ -234,6 +234,7 @@ public class TCTokenRequest {
if (usableCards == null) {
// user aborted the card insertion dialog
LOG.info("Waiting for cards has not returned a result, cancelling process.");
throw new UserCancellationException(null, LANG.translationForKey(CARD_INSERTION_ABORT));
}
......
......@@ -200,7 +200,11 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
public void onStop() {
// make sure nothing is running anymore
cancelAuthenticationInt(false, false);
Thread at = authThread;
if (at != null) {
authThread = null; // prevent calling handler at all, we are shutting down
cancelAuthenticationInt(at, false, false);
}
// remove callback which is set onStart
if (octx != null) {
......@@ -354,19 +358,16 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
@Override
public void cancelAuthentication(boolean runInThread) {
cancelAuthenticationInt(true, runInThread);
cancelAuthenticationInt(authThread, true, runInThread);
}
private void cancelAuthenticationInt(boolean showFailure, boolean runInNewThread) {
Thread at = authThread;
private void cancelAuthenticationInt(Thread at, boolean showFailure, boolean runInNewThread) {
if (at != null) {
// define function
Runnable fun = () -> {
try {
LOG.info("Stopping Authentication thread ...");
at.interrupt();
at.join();
LOG.info("Authentication thread has stopped.");
// cancel task and handle event
if (showFailure) {
......@@ -374,6 +375,10 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
ActivationResult r = new ActivationResult(ActivationResultCode.INTERRUPTED, msg);
handleActivationResult(r);
}
at.join();
LOG.info("Authentication thread has stopped.");
} catch (InterruptedException ex) {
LOG.error("Waiting for Authentication thread interrupted.");
} finally {
......
......@@ -41,6 +41,8 @@ import org.openecard.gui.definition.Text;
import org.openecard.gui.definition.UserConsentDescription;
import org.openecard.gui.executor.ExecutionEngine;
import org.openecard.gui.executor.StepAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
......@@ -52,6 +54,8 @@ import org.openecard.gui.executor.StepAction;
*/
public class InsertCardDialog {
private static final Logger LOG = LoggerFactory.getLogger(InsertCardDialog.class);
private static final String STEP_ID = "insert-card";
private final I18n lang = I18n.getTranslation("tctoken");
......@@ -97,6 +101,7 @@ public class InsertCardDialog {
ResultStatus status = exec.process();
if (status == ResultStatus.CANCEL) {
LOG.info("Waiting for cards dialog has been cancelled.");
return null;
}
evDispatcher.del(insertCardAction);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment