peter-lawrey / Java-Chronicle

Java Indexed Record Chronicle
1.22k stars 193 forks source link

AbstractExcerpt.skipBytes() doesn't skip #8

Closed vlad-ilyushchenko closed 11 years ago

vlad-ilyushchenko commented 12 years ago

on read-only excerpt with 0 capacity skipBytes() ignores input and doesn't skip at all. This can be avoided by removing defensive code:

@Override
public int skipBytes(int n) {
    int position = position();

// int n2 = Math.min(n, capacity - position); position(position + n); return n;

peter-lawrey commented 11 years ago

The capacity is the limit of the Excerpt and you shouldn't be able to move beyond the end. If you need to be able to skip further you should increase the capacity. Note: when appending the capacity can be larger than it needs to be and the finish() method will "shrink wrap" the Excerpt to what you actually used.

BTW There is code which assumes the excerpt is at least 8 bytes long and there is code to enforce that now.