Skip to content

Commit fe9c3fb

Browse files
committed
Fixed bloated connection errors in logs;
Fixed that data update tasks runs after disconnect;
1 parent f811424 commit fe9c3fb

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Mage.Client/src/main/java/mage/client/MageFrame.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1416,11 +1416,11 @@ public void disconnected(final boolean askToReconnect) {
14161416
// USER mode, e.g. user plays and got disconnect
14171417
LOGGER.info("Disconnected from user mode");
14181418
SwingUtilities.invokeLater(() -> {
1419+
SessionHandler.disconnect(false); // user already disconnected, can't do any online actions like quite chat
14191420
setConnectButtonText(NOT_CONNECTED_TEXT);
14201421
disableButtons();
14211422
hideGames();
14221423
hideTables();
1423-
SessionHandler.disconnect(false);
14241424
if (askToReconnect) {
14251425
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + MagePreferences.getLastServerAddress() + "?");
14261426
message.setButton1("No", null);

Mage.Client/src/main/java/mage/client/table/TablesPanel.java

+1
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ public void mouseClicked(MouseEvent e) {
513513
public void cleanUp() {
514514
saveGuiSettings();
515515
chatPanelMain.cleanUp();
516+
stopTasks();
516517
}
517518

518519
public void changeGUISize() {

Mage.Common/src/main/java/mage/remote/SessionImpl.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -1583,12 +1583,24 @@ public boolean lockUser(String userName, long durationMinute) {
15831583
}
15841584

15851585
private void handleThrowable(Throwable t) {
1586-
logger.fatal("Communication error", t);
15871586

1587+
// ignore interrupted exceptions -- it's connection problem or user's close
1588+
if (t instanceof InterruptedException) {
1589+
//logger.error("Connection error: was interrupted", t);
1590+
Thread.currentThread().interrupt();
1591+
return;
1592+
}
1593+
1594+
if (t instanceof RuntimeException) {
1595+
RuntimeException re = (RuntimeException) t;
1596+
if (t.getCause() instanceof InterruptedException) {
1597+
//logger.error("Connection error: was interrupted by runtime exception", t.getCause());
1598+
Thread.currentThread().interrupt();
1599+
return;
1600+
}
1601+
}
15881602

1589-
// Probably this can cause hanging the client under certain circumstances as the disconnect method is synchronized
1590-
// so check if it's needed
1591-
// disconnect(true);
1603+
logger.fatal("Connection error: other", t);
15921604
}
15931605

15941606
private void handleMageException(MageException ex) {

0 commit comments

Comments
 (0)