From b7211d5d67f33b4bc69525c0a1ff4860f3336d43 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 22 May 2016 12:02:12 +0200 Subject: [PATCH] Report illegal Stream Management state Fixes SMACK-721. --- smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java index ac79f118b..c432637be 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java @@ -47,6 +47,9 @@ public class SMUtils { * @return the delta */ public static long calculateDelta(long reportedHandledCount, long lastKnownHandledCount) { + if (lastKnownHandledCount > reportedHandledCount) { + throw new IllegalStateException("Illegal Stream Management State: Last known handled count (" + lastKnownHandledCount + ") is greater than reported handled count (" + reportedHandledCount + ')'); + } return (reportedHandledCount - lastKnownHandledCount) & MASK_32_BIT; } }