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 NPE in s3 scan partition supplier #3317

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

graytaylor0
Copy link
Member

Description

Fixes a potential NPE in the s3 scan partition supplier

Issues Resolved

Resolves #3316

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -101,7 +101,7 @@ private List<PartitionIdentifier> listFilteredS3ObjectsForBucket(final List<Stri
final LocalDateTime endDateTime,
final Map<String, Object> globalStateMap) {

Instant mostRecentLastModifiedTimestamp = globalStateMap.containsKey(bucket) ? Instant.parse((String) globalStateMap.get(bucket)) : null;
Instant mostRecentLastModifiedTimestamp = globalStateMap.containsKey(bucket) && Objects.nonNull(globalStateMap.get(bucket)) ? Instant.parse((String) globalStateMap.get(bucket)) : null;
Copy link
Member

Choose a reason for hiding this comment

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

globalStateMap.containsKey(bucket) && Objects.nonNull(globalStateMap.get(bucket)) can simplify to globalStateMap.get(bucket) != null

Also, Objects.nonNull is not necessary here. It is intended for use where a Predicate is needed.

Signed-off-by: Taylor Gray <[email protected]>
dlvenable
dlvenable previously approved these changes Sep 8, 2023
@dlvenable
Copy link
Member

@graytaylor0 , We should probably have a unit test here as well.

@graytaylor0 graytaylor0 merged commit f61338a into opensearch-project:main Sep 12, 2023
24 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 12, 2023
Fix potential NPE in s3 scan partition supplier

Signed-off-by: Taylor Gray <[email protected]>
(cherry picked from commit f61338a)
dlvenable pushed a commit that referenced this pull request Sep 14, 2023
Fix potential NPE in s3 scan partition supplier

Signed-off-by: Taylor Gray <[email protected]>
(cherry picked from commit f61338a)

Co-authored-by: Taylor Gray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] S3 Scan hits NPE when bucket key has a null value
3 participants