Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-1958

incorrect ordering for reactor timer tasks with matching deadlines

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • proton-j-0.29.0
    • proton-j-0.30.0
    • proton-j
    • 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

          Activity

            People

              robbie Robbie Gemmell
              jdanek Jiri Daněk
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: