fix: runStage null to non-null or cancel via exception #17846
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The
runStage
method that would run aCallable
could returnnull
either from thatCallable
or from theerrorValue
given.This potential NPE was not handled in many places. Often enough it also wasn't an issue as the usage of the returned value was below the next
startingStage
which would fail if thenull
was due to an error so the code would never proceed to use the variable.With the
JobProgress
not having nullness annotations the nullness analysis would warn about potential NPEs from the return values ofrunStage
. To transition the value into a known non-null while keeping the error behaviour of throwing a cancellation exception on next use of progress after a failed stage a new method was added to confirm post run assumptions:The
nonNullStagePostCondition
method takes a potential null value and simply returns it when non-null or throws an exception when it is null.I checked the callers of the
runStage
method and addednonNullStagePostCondition
where the nullness analysis indicated potential NPEs