Make disconnect() not throw NotConnectedException

while disconnect(Presence) still does to notify the user that the
unavailable presence was not send.
This commit is contained in:
Florian Schmaus 2015-01-13 23:09:43 +01:00
parent eb6b8df7c5
commit fc14962445
1 changed files with 7 additions and 7 deletions

View File

@ -643,10 +643,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* the XMPP server. The XMPPConnection can still be used for connecting to the server * the XMPP server. The XMPPConnection can still be used for connecting to the server
* again. * again.
* *
* @throws NotConnectedException
*/ */
public void disconnect() throws NotConnectedException { public void disconnect() {
disconnect(new Presence(Presence.Type.unavailable)); try {
disconnect(new Presence(Presence.Type.unavailable));
}
catch (NotConnectedException e) {
LOGGER.log(Level.FINEST, "Connection is already disconnected", e);
}
} }
/** /**
@ -661,10 +665,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException { public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
if (!isConnected()) {
throw new NotConnectedException();
}
sendPacket(unavailablePresence); sendPacket(unavailablePresence);
shutdown(); shutdown();
callConnectionClosedListener(); callConnectionClosedListener();