Skip to content

Commit dcb89eb

Browse files
committed
Using BsonInput.mark/reset and removed BsonInput.setPosition.
1 parent 413d9b2 commit dcb89eb

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

bson/src/main/org/bson/BsonBinaryReader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,17 @@ public void reset() {
359359
protected class Mark extends AbstractBsonReader.Mark {
360360
private int startPosition;
361361
private int size;
362-
private int currentPosition;
363362

364363
protected Mark() {
365364
super();
366365
startPosition = BsonBinaryReader.this.getContext().startPosition;
367366
size = BsonBinaryReader.this.getContext().size;
368-
currentPosition = BsonBinaryReader.this.bsonInput.getPosition();
367+
BsonBinaryReader.this.bsonInput.mark(Integer.MAX_VALUE);
369368
}
370369

371370
protected void reset() {
372371
super.reset();
373-
BsonBinaryReader.this.bsonInput.setPosition(currentPosition);
372+
BsonBinaryReader.this.bsonInput.reset();
374373
BsonBinaryReader.this.setContext(new Context((Context) getParentContext(), getContextType(), startPosition, size));
375374
}
376375
}

bson/src/main/org/bson/io/BsonInput.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ public interface BsonInput extends Closeable {
3333
*/
3434
int getPosition();
3535

36-
/**
37-
* Sets the position in the stream
38-
*
39-
* @param newPosition the new position
40-
*/
41-
void setPosition(int newPosition);
42-
4336
/**
4437
* Reads a single byte from the stream
4538
*

bson/src/main/org/bson/io/ByteBufferBsonInput.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ public int getPosition() {
5353
return buffer.position();
5454
}
5555

56-
@Override
57-
public void setPosition(final int newPosition) {
58-
ensureOpen();
59-
buffer.position(newPosition);
60-
}
61-
6256

6357
@Override
6458
public byte readByte() {

0 commit comments

Comments
 (0)