Commit 2624387
Use stream channel for size lookup
`database.length()` is a path-based `stat(2)`, which can race with file
replacement between the `FileInputStream` open and the size lookup —
the bytes the stream then delivers may not match the size we read.
Switch to `stream.getChannel().size()`, which is an `fstat` on the
already-open file descriptor and therefore atomic with the open.
`FileChannelImpl.getChannel()` is lazy and `.size()` is a stat-only
syscall, so this does not reintroduce the per-thread direct ByteBuffer
cache that the previous commit was fixing — that cache only grows
when `FileChannel.read(heapByteBuffer)` is called.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cbf83d9 commit 2624387
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
0 commit comments