jpountz commented on code in PR #12357:
URL: https://github.com/apache/lucene/pull/12357#discussion_r1222916518
##########
lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java:
##########
@@ -163,11 +163,11 @@ public final long readLong() throws IOException {
public final byte readByte(long pos) throws IOException {
long index = pos - bufferStart;
if (index < 0 || index >= buffer.limit()) {
- bufferStart = pos;
+ bufferStart = index < 0 ? Math.min(pos, Math.max(0, bufferStart -
bufferSize)) : pos;
Review Comment:
Let's add a comment explaining that this is trying to avoid backward reading
being an adversarial case?
##########
lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java:
##########
@@ -43,7 +43,7 @@ public abstract class BufferedIndexInput extends IndexInput
implements RandomAcc
/** A buffer size for merges set to {@value #MERGE_BUFFER_SIZE}. */
public static final int MERGE_BUFFER_SIZE = 4096;
- private int bufferSize = BUFFER_SIZE;
+ private final int bufferSize;
Review Comment:
I had not realized that the bufferSize could no longer be updated. It's not
directly related to your change but we could fix the `getBufferSize` javadocs
to no longer link to `setBufferSize`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]