Commit 0819c4f
committed
fix: peekLine left buffer in inconsistent state after compaction
peekLine captured csvBuffer.pos at entry and restored that absolute
value at exit. fetchData, however, can compact the buffer mid-scan
(shifting begin to 0 and adjusting pos). The restored absolute
savedPos then pointed past the actual line start in the new layout.
Subsequent skipLine(line.length()) advanced from the wrong base,
eventually pushing pos out of buffer bounds and throwing
StringIndexOutOfBoundsException - or, more dangerously, silently
skipping records.
Restore csvBuffer.pos to csvBuffer.begin instead. The invariant at
peekLine entry is pos == begin (the caller just consumed previous
records via skipLine), so this is equivalent in the no-compact
case, and begin is itself shifted by compaction so it stays
correct across a fetchData compact.
JMH: FastCsvReadBenchmark unchanged within noise.1 parent a6d3de5 commit 0819c4f
2 files changed
Lines changed: 18 additions & 3 deletions
File tree
- lib/src
- intTest/java/blackbox/reader
- main/java/de/siegmar/fastcsv/reader
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
251 | 268 | | |
252 | 269 | | |
253 | 270 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | | - | |
363 | 361 | | |
364 | 362 | | |
365 | 363 | | |
| |||
368 | 366 | | |
369 | 367 | | |
370 | 368 | | |
371 | | - | |
| 369 | + | |
372 | 370 | | |
373 | 371 | | |
374 | 372 | | |
| |||
0 commit comments