uschindler commented on a change in pull request #2052:
URL: https://github.com/apache/lucene-solr/pull/2052#discussion_r558491882
##########
File path:
lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
##########
@@ -307,7 +314,14 @@ public void close() throws IOException {
@Override
public long getFilePointer() {
- return filePos + buffer.position();
+ long filePointer = filePos + buffer.position();
+
+ // opening the input and immediately calling getFilePointer without
calling readX (and thus refill) first,
+ // will result in negative value equal to bufferSize being returned,
+ // due to the initialization method filePos = -bufferSize used in
constructor.
+ assert filePointer == -buffer.capacity() || filePointer >= 0 :
+ "filePointer should either be initial value equal to negative buffer
capacity, or larger than or equal to 0";
+ return Math.max(filePointer, 0);
Review comment:
Thanks, this was driving me crazy when I tried to fix this (I gave up
after some beers deep night).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]