LUCENE-6591: never write a negative vlong

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1686495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-06-19 19:54:02 +00:00
parent b68d571781
commit c9e267f948
2 changed files with 10 additions and 5 deletions

View File

@ -158,6 +158,9 @@ Bug fixes
* LUCENE-6593: Fixed ToChildBlockJoinQuery's scorer to not refuse to advance
to a document that belongs to the parent space. (Adrien Grand)
* LUCENE-6591: Never write a negative vLong (Robert Muir, Ryan Ernst,
Adrien Grand, Mike McCandless)
Changes in Runtime Behavior
* LUCENE-6501: The subreader structure in ParallelCompositeReader

View File

@ -221,12 +221,14 @@ public abstract class DataOutput {
* @see DataInput#readVLong()
*/
public final void writeVLong(long i) throws IOException {
assert i >= 0L;
writeNegativeVLong(i);
if (i < 0) {
throw new IllegalArgumentException("cannot write negative vLong (got: " + i + ")");
}
writeSignedVLong(i);
}
// write a pontentially negative vLong
private void writeNegativeVLong(long i) throws IOException {
// write a potentially negative vLong
private void writeSignedVLong(long i) throws IOException {
while ((i & ~0x7FL) != 0L) {
writeByte((byte)((i & 0x7FL) | 0x80L));
i >>>= 7;
@ -241,7 +243,7 @@ public abstract class DataOutput {
* @see DataInput#readZLong()
*/
public final void writeZLong(long i) throws IOException {
writeNegativeVLong(BitUtil.zigZagEncode(i));
writeSignedVLong(BitUtil.zigZagEncode(i));
}
/** Writes a string.