jenkinsci / jenkinsci/workflow-api-plugin

[JENKINS-40200] MemoryChunk.getLastNode() returns null

Open
#482 0 comments 0 reactions 0 assignees View on GitHub
component:workflow-api-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
31
Forks
80
Avg merge
1d 16h
Merged PRs (30d)
1

Description

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.

---
Originally reported by vivek, imported from: MemoryChunk.getLastNode() returns null


  • status: Open
  • priority: Major
  • component(s): workflow-api-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20260601-173816

Raw content of original issue

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.


Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.