Skip to content

Commit

Permalink
Allow sequenceNumber to wrap from UInt32.MAX to 0
Browse files Browse the repository at this point in the history
fixes #1346
  • Loading branch information
kevinherron committed Nov 27, 2024
1 parent 13a6a8e commit e1cdb05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static boolean validateSequenceNumber(long lastSequenceNumber, long sequenceNumb
return sequenceNumber < 1024 || sequenceNumber == lastSequenceNumber + 1;
} else if (lastSequenceNumber == UInteger.MAX_VALUE) {
// must wrap at this point
return sequenceNumber > 0 && sequenceNumber < 1024;
return sequenceNumber >= 0 && sequenceNumber < 1024;
} else {
return sequenceNumber == lastSequenceNumber + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ void validateSequenceNumbers() {
assertTrue(validateSequenceNumber(UInteger.MAX_VALUE - 1024, i));
}

// wrapping around to anything < 1024 is allowed, from UInteger.MAX_VALUE
for (int i = 0; i < 1024; i++) {
assertTrue(validateSequenceNumber(UInteger.MAX_VALUE, i));
}

// wrapping around to >= 1024 is not allowed
for (int i = 1024; i < 2048; i++) {
assertFalse(validateSequenceNumber(UInteger.MAX_VALUE - 1024, i));
Expand Down

0 comments on commit e1cdb05

Please sign in to comment.