Skip to content

Commit be34421

Browse files
committed
fix checkstyle.
1 parent 560935a commit be34421

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import java.util.List;
106106
import java.util.Map;
107107
import java.util.regex.Pattern;
108+
import java.util.concurrent.atomic.AtomicReference;
108109

109110
import static org.junit.Assert.assertArrayEquals;
110111
import static org.junit.Assert.assertEquals;
@@ -2158,35 +2159,45 @@ private void testGetECCodecs() throws Exception {
21582159
return;
21592160
}
21602161
final Path path = new Path("/foo");
2162+
21612163
FileSystem fs = FileSystem.get(path.toUri(), this.getProxiedFSConf());
2162-
if (fs instanceof DistributedFileSystem) {
2163-
DistributedFileSystem dfs =
2164-
(DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf());
2165-
FileSystem httpFs = this.getHttpFSFileSystem();
2164+
LambdaTestUtils.intercept(AssertionError.class, () -> {
2165+
if (!(fs instanceof DistributedFileSystem)) {
2166+
throw new AssertionError(fs.getClass().getSimpleName() +
2167+
" is not of type DistributedFileSystem.");
2168+
}
2169+
});
21662170

2167-
Map<String, String> dfsAllErasureCodingCodecs = dfs.getAllErasureCodingCodecs();
2168-
Map<String, String> diffErasureCodingCodecs = null;
2171+
DistributedFileSystem dfs =
2172+
(DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf());
2173+
FileSystem httpFs = this.getHttpFSFileSystem();
21692174

2175+
Map<String, String> dfsErasureCodingCodecs = dfs.getAllErasureCodingCodecs();
2176+
2177+
final AtomicReference<Map<String, String>> diffErasureCodingCodecsRef =
2178+
new AtomicReference<>();
2179+
LambdaTestUtils.intercept(AssertionError.class, () -> {
21702180
if (httpFs instanceof HttpFSFileSystem) {
2171-
HttpFSFileSystem httpFS = (HttpFSFileSystem) httpFs;
2172-
diffErasureCodingCodecs = httpFS.getAllErasureCodingCodecs();
2181+
HttpFSFileSystem httpFSFileSystem = (HttpFSFileSystem) httpFs;
2182+
diffErasureCodingCodecsRef.set(httpFSFileSystem.getAllErasureCodingCodecs());
21732183
} else if (httpFs instanceof WebHdfsFileSystem) {
21742184
WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
2175-
diffErasureCodingCodecs = webHdfsFileSystem.getAllErasureCodingCodecs();
2185+
diffErasureCodingCodecsRef.set(webHdfsFileSystem.getAllErasureCodingCodecs());
21762186
} else {
2177-
Assert.fail(fs.getClass().getSimpleName() +
2187+
throw new AssertionError(httpFs.getClass().getSimpleName() +
21782188
" is not of type HttpFSFileSystem or WebHdfsFileSystem");
21792189
}
2190+
});
2191+
Map<String, String> diffErasureCodingCodecs = diffErasureCodingCodecsRef.get();
21802192

2181-
//Validate testGetECCodecs are the same as DistributedFileSystem
2182-
Assert.assertEquals(dfsAllErasureCodingCodecs.size(), diffErasureCodingCodecs.size());
2193+
//Validate testGetECCodecs are the same as DistributedFileSystem
2194+
Assert.assertEquals(dfsErasureCodingCodecs.size(), diffErasureCodingCodecs.size());
21832195

2184-
for (Map.Entry<String, String> entry : dfsAllErasureCodingCodecs.entrySet()) {
2185-
Assert.assertTrue(diffErasureCodingCodecs.containsKey(entry.getKey()));
2186-
Assert.assertEquals(entry.getValue(), diffErasureCodingCodecs.get(entry.getKey()));
2187-
}
2188-
} else {
2189-
Assert.fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
2196+
for (Map.Entry<String, String> entry : dfsErasureCodingCodecs.entrySet()) {
2197+
String key = entry.getKey();
2198+
String value = entry.getValue();
2199+
Assert.assertTrue(diffErasureCodingCodecs.containsKey(key));
2200+
Assert.assertEquals(value, diffErasureCodingCodecs.get(key));
21902201
}
21912202
}
21922203

0 commit comments

Comments
 (0)