Skip to content

Commit

Permalink
feedback review.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshuyan0 committed Jul 18, 2023
1 parent e089eff commit 6515ee7
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
*/
package org.apache.hadoop.fs.viewfs;

import static org.apache.hadoop.test.LambdaTestUtils.intercept;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.test.AbstractHadoopTestBase;
import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class TestViewFileSystemClose {
public class TestViewFileSystemClose extends AbstractHadoopTestBase {

/**
* Verify that all child file systems of a ViewFileSystem will be shut down
* when the cache is disabled.
* @throws IOException
*/
@Test
public void testFileSystemLeak() throws IOException {
public void testFileSystemLeak() throws Exception {

Configuration conf = new Configuration();
conf.set("fs.viewfs.impl", ViewFileSystem.class.getName());
Expand All @@ -53,12 +53,9 @@ public void testFileSystemLeak() throws IOException {
viewFs.close();
FileSystem.closeAll();
for (FileSystem fs : children) {
try {
fs.create(new Path(rootPath, "neverSuccess"));
fail();
} catch (IOException ioe) {
assertTrue(ioe.getMessage().contains("Filesystem closed"));
}
intercept(IOException.class, "Filesystem closed",
"Expect Filesystem closed IOException",
() -> fs.create(new Path(rootPath, "neverSuccess")));
}
}
}

0 comments on commit 6515ee7

Please sign in to comment.