diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 4f28dc633..86dea74da 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1612,7 +1612,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { throw new StreamManagementException.StreamManagementNotEnabledException(); } // Remove the listener after max. 12 hours - final int removeAfterSeconds = Math.min(getMaxSmResumptionTime() + 60, 12 * 60 * 60); + final int removeAfterSeconds = Math.min(getMaxSmResumptionTime(), 12 * 60 * 60); schedule(new Runnable() { @Override public void run() { @@ -1703,8 +1703,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { /** * Get the maximum resumption time in seconds after which a managed stream can be resumed. + *

+ * This method will return {@link Integer#MAX_VALUE} if neither the client nor the server specify a maximum + * resumption time. Be aware of integer overflows when using this value, e.g. do not add arbitrary values to it + * without checking for overflows before. + *

* - * @return the maximum resumption time in seconds. + * @return the maximum resumption time in seconds or {@link Integer#MAX_VALUE} if none set. */ public int getMaxSmResumptionTime() { int clientResumptionTime = smClientMaxResumptionTime > 0 ? smClientMaxResumptionTime : Integer.MAX_VALUE;