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

[DUOS-2851][risk=no] Minor safety check for studies with no datasets #2212

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

rushtong
Copy link
Contributor

Addresses

https://broadworkbench.atlassian.net/browse/DUOS-2851

Summary

Minor null check to capture studies with empty datasets


Have you read CONTRIBUTING.md lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@rushtong rushtong requested a review from a team as a code owner December 14, 2023 19:11
Copy link
Contributor

@hams7504 hams7504 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 👍

Comment on lines 65 to 70
Optional<Dataset> dataset = Objects.nonNull(existingStudy.getDatasets()) ? existingStudy
.getDatasets()
.stream()
.filter(d -> d.getDataSetId().equals(cg.getDatasetId()))
.findFirst();
.findFirst() :
Optional.empty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like, here is another way to handle this (we like ListUtils.emptyIfNull in TDR for cases like this):

import org.apache.commons.collections4.ListUtils;

…

Optional<Dataset> dataset =
  ListUtils.emptyIfNull(existingStudy.getDatasets())
    .stream()
    .filter(d -> d.getDataSetId().equals(cg.getDatasetId()))
    .findFirst();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that does look cleaner!

@rushtong rushtong merged commit f9feb8d into develop Dec 15, 2023
@rushtong rushtong deleted the gr-DUOS-2851-npe-fix branch December 15, 2023 20:15
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