Skip to content

Commit

Permalink
Merge pull request zaproxy#2431 from thc202/output-auth-message-async
Browse files Browse the repository at this point in the history
Fix InterruptedException while stopping the spider
  • Loading branch information
psiinon committed Apr 25, 2016
2 parents 9c48c81 + a882e19 commit 4fe6562
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/org/parosproxy/paros/view/OutputPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 17 additions & 7 deletions src/org/zaproxy/zap/authentication/AuthenticationHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zaproxy.zap.authentication;

import java.awt.EventQueue;
import java.io.IOException;

import org.apache.commons.httpclient.HttpState;
Expand Down Expand Up @@ -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");
}
}

Expand All @@ -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");
}
}

Expand All @@ -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);
Expand Down

0 comments on commit 4fe6562

Please sign in to comment.