mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
For Issue#524: added connect task timeout, reduced number of auto connection retries to one
This commit is contained in:
parent
089a990b26
commit
3454b2db8a
2 changed files with 11 additions and 3 deletions
|
|
@ -54,6 +54,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -321,6 +323,8 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
private boolean result = false;
|
||||
|
||||
private static final int CONNECTION_TIMEOUT_MS = 2100;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground() throws Exception {
|
||||
lblStatus.setText("Connecting...");
|
||||
|
|
@ -332,7 +336,7 @@ public class ConnectDialog extends MageDialog {
|
|||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
get(CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
if (result) {
|
||||
lblStatus.setText("");
|
||||
|
|
@ -348,8 +352,10 @@ public class ConnectDialog extends MageDialog {
|
|||
} catch (CancellationException ex) {
|
||||
logger.info("Connect was canceled");
|
||||
lblStatus.setText("Connect was canceled");
|
||||
MageFrame.stopConnecting();
|
||||
} catch (TimeoutException ex) {
|
||||
logger.fatal("Connection timeout: ", ex);
|
||||
} finally {
|
||||
MageFrame.stopConnecting();
|
||||
btnConnect.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue