Skip to content

Commit 7b34f01

Browse files
committed
SortedTextFile#searchOffset() fix NPE causing ARI-3498; also return "offset" instead of "offset-2", don't get reason for -2 and it can return nonsensical result -2 when offset is 0
1 parent 656dd75 commit 7b34f01

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/main/java/org/archive/util/binsearch/SortedTextFile.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,11 @@ private long searchOffset(SeekableLineReader slr,
378378
prev = line;
379379
}
380380

381-
if (!lessThan) {
382-
prev = null;
383-
} else {
381+
if (lessThan && prev != null) {
384382
offset -= prev.getBytes().length + 1;
385-
}
383+
}
386384

387-
// To allow for skipping the line, in case we're not on the boundary
388-
return (offset - 2);
385+
return offset;
389386
}
390387

391388
private CloseableIterator<String> search(SeekableLineReader slr,

0 commit comments

Comments
 (0)