Skip to content

Commit

Permalink
Fix NPE in s3 scan partition supplier (#3317) (#3323)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
opensearch-trigger-bot[bot] and graytaylor0 authored Sep 14, 2023
1 parent ad15f71 commit 3cf8f40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.get(bucket) != null ? Instant.parse((String) globalStateMap.get(bucket)) : null;
final List<PartitionIdentifier> allPartitionIdentifiers = new ArrayList<>();
ListObjectsV2Response listObjectsV2Response = null;
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void getNextPartition_supplier_without_scheduling_options_returns_expected_Parti
assertThat(globalStateMap.containsKey(SCAN_COUNT), equalTo(true));
assertThat(globalStateMap.get(SCAN_COUNT), equalTo(1));

globalStateMap.put(secondBucket, null);

assertThat(partitionCreationSupplier.apply(globalStateMap), equalTo(Collections.emptyList()));

assertThat(resultingPartitions, notNullValue());
Expand Down

0 comments on commit 3cf8f40

Please sign in to comment.