uschindler commented on issue #16937:
URL: https://github.com/apache/lucene/issues/16937#issuecomment-6508981328
LFV-140 is not an issue, but the documentation should be improved.
Background: Once you hit an `IOException` (specifically `EOFException`in the
current case), the internal state of the `IndexInput` is broken and reads or
seeks after that happened are no longer behaving as expected.
For the seek call this was 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`. Actually the problem of LFV-140 is excatly that: 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.
I opened #16951 to fix the documentation and starting a discussion.
--
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]