Skip to content

Commit

Permalink
Ensure that we don't pass negative timeInQueue to writeVLong
Browse files Browse the repository at this point in the history
`#writeVLong` can only serialize positive values, yet this BWC code
in `PendingClusterTask` passes occational `-1` causing assertions to trip.
It also yields completely wrong values ie. if `-1 is deserialized it yields
`9223372036854775807`. This commit ensure that `timeInQueue` is positive ie.
at least `0`

Relates to elastic#8077
  • Loading branch information
s1monw committed Feb 11, 2015
1 parent d7d0831 commit 8143a49
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -98,8 +98,8 @@ public void writeTo(StreamOutput out) throws IOException {
// timeInQueue is set to -1 when unknown and can be negative if time goes backwards
out.writeLong(timeInQueue);
} else {
out.writeVLong(timeInQueue);
}
out.writeVLong(Math.max(0, timeInQueue));
}
if (out.getVersion().onOrAfter(Version.V_1_3_0)) {
out.writeBoolean(executing);
}
Expand Down

0 comments on commit 8143a49

Please sign in to comment.