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.
Above code will cause NPE as chunk.getLastNode() returns null. This happens with non-block stage scripts where one stage follows another.
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.