From f11134dc4c5e478d967ce1e6c5bf92624e696b4e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 7 Apr 2018 21:15:20 +0200 Subject: [PATCH] Remove deprecated reconnection callbacks in ConnectionListener Fixes SMACK-776. --- .../smack/AbstractConnectionListener.java | 17 --------- .../smack/AbstractXMPPConnection.java | 19 ---------- .../smack/ConnectionListener.java | 37 ------------------- .../smack/ReconnectionManager.java | 9 ----- .../jivesoftware/smack/DummyConnection.java | 9 ----- 5 files changed, 91 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractConnectionListener.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractConnectionListener.java index 85d027220..f593a4ce3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractConnectionListener.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractConnectionListener.java @@ -45,21 +45,4 @@ public class AbstractConnectionListener implements ConnectionListener { // do nothing } - @Deprecated - @Override - public void reconnectingIn(int seconds) { - // do nothing - } - - @Deprecated - @Override - public void reconnectionFailed(Exception e) { - // do nothing - } - - @Deprecated - @Override - public void reconnectionSuccessful() { - // do nothing - } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 446ce7502..61e4c12a0 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -1279,25 +1279,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } - /** - * Sends a notification indicating that the connection was reconnected successfully. - */ - // TODO: Remove in Smack 4.3 - @Deprecated - protected void notifyReconnection() { - // Notify connection listeners of the reconnection. - for (ConnectionListener listener : connectionListeners) { - try { - listener.reconnectionSuccessful(); - } - catch (Exception e) { - // Catch and print any exception so we can recover - // from a faulty listener - LOGGER.log(Level.WARNING, "notifyReconnection()", e); - } - } - } - /** * A wrapper class to associate a stanza filter with a listener. */ diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionListener.java b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionListener.java index c096e48b2..cecabcf71 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionListener.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionListener.java @@ -61,41 +61,4 @@ public interface ConnectionListener { */ void connectionClosedOnError(Exception e); - /** - * The connection has reconnected successfully to the server. Connections will - * reconnect to the server when the previous socket connection was abruptly closed. - * @deprecated use {@link #connected(XMPPConnection)} or {@link #authenticated(XMPPConnection, boolean)} instead. - */ - // TODO: Remove in Smack 4.3 - @Deprecated - void reconnectionSuccessful(); - - // The next two methods *must* only be invoked by ReconnectionManager - - /** - * The connection will retry to reconnect in the specified number of seconds. - *

- * Note: This method is only called if {@link ReconnectionManager#isAutomaticReconnectEnabled()} returns true, i.e. - * only when the reconnection manager is enabled for the connection. - *

- * - * @param seconds remaining seconds before attempting a reconnection. - */ - // TODO: Remove in Smack 4.3 - @Deprecated - void reconnectingIn(int seconds); - - /** - * An attempt to connect to the server has failed. The connection will keep trying reconnecting to the server in a - * moment. - *

- * Note: This method is only called if {@link ReconnectionManager#isAutomaticReconnectEnabled()} returns true, i.e. - * only when the reconnection manager is enabled for the connection. - *

- * - * @param e the exception that caused the reconnection to fail. - */ - // TODO: Remove in Smack 4.3 - @Deprecated - void reconnectionFailed(Exception e); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java b/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java index 0f7d65dec..d3cc212f2 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java @@ -262,9 +262,6 @@ public final class ReconnectionManager { for (ReconnectionListener listener : reconnectionListeners) { listener.reconnectingIn(remainingSeconds); } - for (ConnectionListener listener : connection.connectionListeners) { - listener.reconnectingIn(remainingSeconds); - } } catch (InterruptedException e) { LOGGER.log(Level.FINE, "Reconnection Thread was interrupted, aborting reconnection mechanism", e); @@ -276,9 +273,6 @@ public final class ReconnectionManager { for (ReconnectionListener listener : reconnectionListeners) { listener.reconnectingIn(0); } - for (ConnectionListener listener : connection.connectionListeners) { - listener.reconnectingIn(0); - } if (!isReconnectionPossible(connection)) { return; @@ -304,9 +298,6 @@ public final class ReconnectionManager { for (ReconnectionListener listener : reconnectionListeners) { listener.reconnectionFailed(e); } - for (ConnectionListener listener : connection.connectionListeners) { - listener.reconnectionFailed(e); - } // Failed to reconnect, try again. continue; } catch (InterruptedException e) { diff --git a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java index 75d2a29e1..c8c425251 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java @@ -53,8 +53,6 @@ import org.jxmpp.stringprep.XmppStringprepException; */ public class DummyConnection extends AbstractXMPPConnection { - private boolean reconnect = false; - private final BlockingQueue queue = new LinkedBlockingQueue(); public static ConnectionConfiguration.Builder getDummyConfigurationBuilder() { @@ -88,16 +86,10 @@ public class DummyConnection extends AbstractXMPPConnection { user = getUserJid(); } - @SuppressWarnings("deprecation") @Override protected void connectInternal() { connected = true; streamId = "dummy-" + new Random(new Date().getTime()).nextInt(); - - // TODO: Remove in Smack 4.3, and likely the suppression of the deprecation warning. - if (reconnect) { - notifyReconnection(); - } } @Override @@ -106,7 +98,6 @@ public class DummyConnection extends AbstractXMPPConnection { authenticated = false; callConnectionClosedListener(); - reconnect = true; } @Override