[
https://issues.apache.org/jira/browse/PROTON-1958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16676721#comment-16676721
]
ASF subversion and git services commented on PROTON-1958:
---------------------------------------------------------
Commit 83609c4752fbdaa1ddfa032285e5caa09b61f480 in qpid-proton-j's branch
refs/heads/master from [~gemmellr]
[ https://git-wip-us.apache.org/repos/asf?p=qpid-proton-j.git;h=83609c4 ]
PROTON-1958: use a per-Timer counter value such that its Tasks naturally order
if their deadlines are equal
> incorrect ordering for reactor timer tasks with matching deadlines
> ------------------------------------------------------------------
>
> Key: PROTON-1958
> URL: https://issues.apache.org/jira/browse/PROTON-1958
> Project: Qpid Proton
> Issue Type: Bug
> Components: proton-j
> Affects Versions: proton-j-0.29.0
> Reporter: Jiri Daněk
> Assignee: Robbie Gemmell
> Priority: Major
> Fix For: proton-j-0.30.0
>
>
> 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.
> {code:java}
> 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;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]