mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
[core] Synchronize notifyConnectionError()
Synchronize notifyConnectionError() so that only one exception is
handled and remove the ASYNC_BUT_ORDERED usage here. The
ASYNC_BUT_ORDERED was added with 7d2c3ac9f
("Do not call synchronized
methods in reader/writer thread"), but is no longer necessary, since
the Semaphores where replaced with conditions in the previous commit.
This commit is contained in:
parent
57961a8cc1
commit
81f10b0c5b
1 changed files with 9 additions and 8 deletions
|
@ -963,6 +963,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
callConnectionClosedListener();
|
||||
}
|
||||
|
||||
private final Object notifyConnectionErrorMonitor = new Object();
|
||||
|
||||
/**
|
||||
* Sends out a notification that there was an error with the connection
|
||||
* and closes the connection.
|
||||
|
@ -970,14 +972,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param exception the exception that causes the connection close event.
|
||||
*/
|
||||
protected final void notifyConnectionError(final Exception exception) {
|
||||
if (!isConnected()) {
|
||||
LOGGER.log(Level.INFO, "Connection was already disconnected when attempting to handle " + exception,
|
||||
exception);
|
||||
return;
|
||||
}
|
||||
synchronized (notifyConnectionErrorMonitor) {
|
||||
if (!isConnected()) {
|
||||
LOGGER.log(Level.INFO, "Connection was already disconnected when attempting to handle " + exception,
|
||||
exception);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Remove this async but ordered?
|
||||
ASYNC_BUT_ORDERED.performAsyncButOrdered(this, () -> {
|
||||
// Note that we first have to set the current connection exception and notify waiting threads, as one of them
|
||||
// could hold the instance lock, which we also need later when calling instantShutdown().
|
||||
setCurrentConnectionExceptionAndNotify(exception);
|
||||
|
@ -995,7 +996,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
// Notify connection listeners of the error.
|
||||
callConnectionClosedOnErrorListener(exception);
|
||||
}, AbstractXMPPConnection.this + " callConnectionClosedOnErrorListener()");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue