Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21997

LeftItem.executable == null during QueueListener.onLeft

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      The QueueListener.onLeft listener callback sounds useful, except when it is called you cannot use LeftItem.getExecutable()—it is always null (even for a build which was not canceled).

      https://github.com/jenkinsci/jenkins/blob/334ce1be691c96ad63642c8301c4f0417a0705c3/core/src/main/java/hudson/model/Executor.java#L207

      Queue.onStartExecuting is called, which triggers the listener. Immediately afterward, WorkUnit.setExecutable is called, but that is too late for the listener.

      The fix would presumably be to have onStartExecuting return its LeftItem, and make Executor.run be responsible for calling QueueListener.onLeft in this case. (The other case is Queue.cancel.)

      Or perhaps it suffices to call Queue.onStartExecuting after WorkUnit.setExecutable. Unclear if that is safe; onStartExecuting also removes the BuildableItem from pendings, and is synchronized, so maybe that would introduce a race condition.

            kohsuke Kohsuke Kawaguchi
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: