From f7c878a9e2adb15883d1961c573821345b689ad4 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Thu, 5 Sep 2019 13:34:22 +0100 Subject: [PATCH] HADOOP-16490 add an extra assert to ITestS3GuardTtl 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 --- .../apache/hadoop/fs/s3a/ITestS3GuardTtl.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3GuardTtl.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3GuardTtl.java index 06032d1516c02..fb539a812f5dc 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3GuardTtl.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3GuardTtl.java @@ -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; @@ -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 containedPaths = fullDLM.getListing().stream() .map(pm -> pm.getFileStatus().getPath()) .collect(Collectors.toList()); @@ -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()); @@ -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; + } + }