jenkinsci / jenkinsci/workflow-api-plugin
[JENKINS-40200] MemoryChunk.getLastNode() returns null
- 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
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
Assessment
This issue has not been assessed yet.