Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
proton-j-0.29.0
-
None
Description
When reactor timer tasks are scheduled with the same deadline, there is some handling in the task compareTo handling which looks to impose a first-scheduled order on them. This isn't effective though as the counter value used in the effort is erroneously always equal. Each timer should index its tasks to ensure they can be ordered on the expected first-scheduled basis when tasks have equal deadlines.
===============
Original description:
Looking at the implementation, it seems that every instance of TaskImpl has this.counter == 0. This seems wrong. The count field should be static for the instance id to work.
public class TaskImpl implements Task, Comparable<TaskImpl> { [...] private final AtomicInteger count = new AtomicInteger(); [...] public TaskImpl(long deadline) { this.deadline = deadline; this.counter = count.getAndIncrement(); } @Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; }
Attachments
Issue Links
- links to