Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: runStage null to non-null or cancel via exception #17846

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Jun 20, 2024

Summary

The runStage method that would run a Callable could return null either from that Callable or from the errorValue 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 the null 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 of runStage. 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 added nonNullStagePostCondition where the nullness analysis indicated potential NPEs

@jbee jbee self-assigned this Jun 20, 2024
Copy link

sonarcloud bot commented Jun 20, 2024

@jbee jbee marked this pull request as ready for review June 20, 2024 10:12
@jbee jbee merged commit d918acb into dhis2:master Jun 20, 2024
15 checks passed
jbee added a commit to jbee/dhis2-core that referenced this pull request Sep 4, 2024
jbee added a commit to jbee/dhis2-core that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants