Skip to content

Commit

Permalink
HADOOP-16490 add an extra assert to ITestS3GuardTtl
Browse files Browse the repository at this point in the history
Gabor reported an NPE here on a test run of this PR only; added asserts that the lists from the MS are never null

Change-Id: I9154eadabb486f601f86e51121d2f05d912c8e46
  • Loading branch information
steveloughran committed Sep 5, 2019
1 parent ac75d6a commit f7c878a
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hadoop.fs.s3a;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -331,7 +332,7 @@ public void testListingFilteredExpiredItems() throws Exception {

// listing will contain the tombstone with oldtime
when(mockTimeProvider.getNow()).thenReturn(oldTime);
final DirListingMetadata fullDLM = ms.listChildren(baseDirPath);
final DirListingMetadata fullDLM = getDirListingMetadata(ms, baseDirPath);
List<Path> containedPaths = fullDLM.getListing().stream()
.map(pm -> pm.getFileStatus().getPath())
.collect(Collectors.toList());
Expand All @@ -342,7 +343,8 @@ public void testListingFilteredExpiredItems() throws Exception {

// listing will be filtered, and won't contain the tombstone with oldtime
when(mockTimeProvider.getNow()).thenReturn(newTime);
final DirListingMetadata filteredDLM = ms.listChildren(baseDirPath);
final DirListingMetadata filteredDLM = getDirListingMetadata(ms,
baseDirPath);
containedPaths = filteredDLM.getListing().stream()
.map(pm -> pm.getFileStatus().getPath())
.collect(Collectors.toList());
Expand All @@ -356,4 +358,14 @@ public void testListingFilteredExpiredItems() throws Exception {
}
}

protected DirListingMetadata getDirListingMetadata(final MetadataStore ms,
final Path baseDirPath) throws IOException {
final DirListingMetadata fullDLM = ms.listChildren(baseDirPath);
Assertions.assertThat(fullDLM)
.describedAs("Metastrore directory listing of %s",
baseDirPath)
.isNotNull();
return fullDLM;
}

}

0 comments on commit f7c878a

Please sign in to comment.