Skip to content

Commit 75f95f7

Browse files
authored
Fix element count calculation issue (#252)
1 parent e72c1ce commit 75f95f7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • persistence/binary/src/main/java/org/eclipse/serializer/persistence/binary/types

persistence/binary/src/main/java/org/eclipse/serializer/persistence/binary/types/Binary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,9 +2096,10 @@ private static void validatePostIterationState(
20962096
// (19.03.2019 TM)NOTE: added "|| iterator.hasNext()" check
20972097
if(address != elementsBinaryBound || iterator.hasNext())
20982098
{
2099+
final long iteratedCount = elementCount - (elementsBinaryBound - address) / entryLength;
20992100
throw new BinaryPersistenceException(
21002101
"Inconsistent element count: specified " + elementCount
2101-
+ " vs. iterated " + elementsBinaryBound / entryLength
2102+
+ " vs. iterated " + (iterator.hasNext() ? "more than " + iteratedCount : iteratedCount)
21022103
);
21032104
}
21042105
}

0 commit comments

Comments
 (0)