uschindler opened a new issue, #16951:
URL: https://github.com/apache/lucene/issues/16951

   ### Description
   
   There is a problem in many IndexInputs with internal state after an 
Exception occurred. For the seek call this is already documented ("then the 
stream is in an undetermined state"):
   
   ```java
     /**
      * Sets current position in this file, where the next read will occur. If 
this is beyond the end
      * of the file then this will throw {@code EOFException} and then the 
stream is in an undetermined
      * state.
      *
      * @see #getFilePointer()
      */
     public abstract void seek(long pos) throws IOException;
   ```
   
   Basically the problem is that this may happen also when you read and hit 
`EOFException` (or any other `IOException`). In `MemorySegmentIndexInput` it 
may for example happen that you seek to end of file, read a byte, hit 
`EOFException` and then seek to some other place. The first seek succeeds (end 
of file), but then the next `readByte(()` throws `IOException`. After that the 
stream's state is undetermined (which is undocumented). Therefor the later seek 
succeeds and the read, too because the internal state is totally f*cked up.
   
   Basically it would be best to add the following sentence to `IndexInput`'s 
class javadocs:
   
   > If any read or seek goes beyond the end of the file then this will throw 
`EOFException`. If any read or seek throws an `IOException` (including 
`EOFException`), then the stream is in an undetermined and it is recommended to 
close it.
   
   Relates to an AI discovered "bug" (which is none if this is fixed in 
documentation): LFV-140 (see #16937).


-- 
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]

Reply via email to