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

MemoryChunk.getLastNode() returns null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • workflow-api-plugin
    • None

      MemoryChunk.getLastNode() returns null although FlowChunk.getLastNode() has @NonNull on it. This causes NPE in other usage, such as when calling StatusAndTiming.computeChunkTiming() in graph analysis, where it expects lastNode to be non-null.

      StatusAndTiming.computeChunkTiming(run, chunk.getPauseTimeMillis(), firstExecuted, chunk.getLastNode(), chunk.getNodeAfter());
      

      Above code will cause NPE as chunk.getLastNode() returns null. This happens with non-block stage scripts where one stage follows another.

      node {
          stage 'Stage 1'
          stage 'Stage 2'
             echo 'hello'
      }
      

      I can work around in my code by checking chunk.getLastNode() as being not null, but this results in this confusing API where @Nonnull contract is broken resulting in to NPE and consumers putting null check after the fact.

            Unassigned Unassigned
            vivek Vivek Pandey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: