diff --git a/src/org/parosproxy/paros/view/OutputPanel.java b/src/org/parosproxy/paros/view/OutputPanel.java index 5bd5735c242..c0ac08880a2 100644 --- a/src/org/parosproxy/paros/view/OutputPanel.java +++ b/src/org/parosproxy/paros/view/OutputPanel.java @@ -214,4 +214,21 @@ private void doAppend(String message){ getTxtOutput().append(message); } + /** + * Appends the given {@code message} to the panel, asynchronously in the EDT. + * + * @param message the message to append to the output panel + * @since TODO add version + * @see EventQueue#invokeLater(Runnable) + */ + public void appendAsync(final String message) { + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + doAppend(message); + } + }); + } + } // @jve:decl-index=0:visual-constraint="10,10" diff --git a/src/org/zaproxy/zap/authentication/AuthenticationHelper.java b/src/org/zaproxy/zap/authentication/AuthenticationHelper.java index 84e3dc67061..11d0b7ca011 100644 --- a/src/org/zaproxy/zap/authentication/AuthenticationHelper.java +++ b/src/org/zaproxy/zap/authentication/AuthenticationHelper.java @@ -1,5 +1,6 @@ package org.zaproxy.zap.authentication; +import java.awt.EventQueue; import java.io.IOException; import org.apache.commons.httpclient.HttpState; @@ -57,7 +58,7 @@ public static void notifyOutputAuthSuccessful(HttpMessage msg) { // Let the user know it worked if (View.isInitialised()) { View.getSingleton().getOutputPanel() - .append(Constant.messages.getString("authentication.output.success") + "\n"); + .appendAsync(Constant.messages.getString("authentication.output.success") + "\n"); } } @@ -71,7 +72,7 @@ public static void notifyOutputAuthFailure(HttpMessage msg) { // Let the user know it failed if (View.isInitialised()) { View.getSingleton().getOutputPanel() - .append(Constant.messages.getString("authentication.output.failure") + "\n"); + .appendAsync(Constant.messages.getString("authentication.output.failure") + "\n"); } } @@ -84,13 +85,22 @@ public HttpState getCorrespondingHttpState() { public static void addAuthMessageToHistory(HttpMessage msg) { // Add message to history try { - HistoryReference ref = new HistoryReference(Model.getSingleton().getSession(), + final HistoryReference ref = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_AUTHENTICATION, msg); ref.addTag(HISTORY_TAG_AUTHENTICATION); - ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader() - .getExtension(ExtensionHistory.class); - if (extHistory != null) { - extHistory.addHistory(ref); + if (View.isInitialised()) { + final ExtensionHistory extHistory = Control.getSingleton() + .getExtensionLoader() + .getExtension(ExtensionHistory.class); + if (extHistory != null) { + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + extHistory.addHistory(ref); + } + }); + } } } catch (Exception ex) { log.error("Cannot add authentication message to History tab.", ex);