Skip to content
Browse files

Fix erroneuous assertion in BasicTimestamp.

The assertion in the ctor failed if more than one document (with a
Timestamp) were in the buffer. (Some commits ago I failed to fix
BasicTimestamp as I did with BasicObjectId ... but hey! Better later
than never, right?)
  • Loading branch information...
1 parent ffd6f0c commit c5ba053bcd619ba947a70f00a52fffb007d37b4e @kohanyirobert committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/main/java/com/github/kohanyirobert/ebson/BasicTimestamp.java
View
6 src/main/java/com/github/kohanyirobert/ebson/BasicTimestamp.java
@@ -19,12 +19,14 @@
private final ByteBuffer timestamp = ByteBuffer.allocate(TIMESTAMP_LENGTH).order(ByteOrder.LITTLE_ENDIAN);
BasicTimestamp(ByteBuffer buffer) {
- int oldLimit = buffer.limit();
+ int oldPosition = buffer.position();
+ int oldLimit = buffer.limit();
buffer.limit(buffer.position() + TIMESTAMP_LENGTH);
timestamp.put(buffer).flip();
+ buffer.limit(oldLimit);
- assert buffer.limit() == oldLimit;
+ assert buffer.position() == oldPosition + TIMESTAMP_LENGTH;
time = ByteBuffer.wrap(timestamp.array(), 0, TIME_LENGTH).order(ByteOrder.LITTLE_ENDIAN);
increment = ByteBuffer.wrap(timestamp.array(), INCREMENT_LENGTH, TIME_LENGTH).order(ByteOrder.LITTLE_ENDIAN);

0 comments on commit c5ba053

Please sign in to comment.
Something went wrong with that request. Please try again.