From a29beddb713aa38be8d0ab9a43dd3eae8da31915 Mon Sep 17 00:00:00 2001 From: Florian Seligmann Date: Sun, 22 Sep 2024 22:45:24 +0200 Subject: [PATCH] explicitly create the swing password panel on the swing thread --- .../grading/git/SSHCloningStrategy.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java index ba40d87..9a4b8ca 100644 --- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java +++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java @@ -2,14 +2,10 @@ package edu.kit.kastel.sdq.artemis4j.grading.git; import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.util.Optional; -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPasswordField; +import javax.swing.*; import edu.kit.kastel.sdq.artemis4j.ArtemisNetworkException; import edu.kit.kastel.sdq.artemis4j.grading.ArtemisConnection; @@ -136,8 +132,14 @@ public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCreden } } else if (item instanceof CredentialItem.Password passwordItem) { if (this.passphrase == null) { - this.passphrase = PasswordPanel.show("Clone via SSH", passwordItem.getPromptText()) - .orElse(null); + try { + SwingUtilities.invokeAndWait(() -> { + this.passphrase = PasswordPanel.show("Clone via SSH", passwordItem.getPromptText()) + .orElse(null); + }); + } catch (InterruptedException | InvocationTargetException e) { + throw new RuntimeException(e); + } } if (this.passphrase != null) {