Skip to content

Commit cad2909

Browse files
Sanjay Radiarichkadel
authored andcommitted
HADOOP-9433 TestLocalFileSystem#testHasFileDescriptor leaks file handle (Chris Nauroth via sanjay)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1460922 13f79535-47bb-0310-9956-ffa450edef68
1 parent 29166a6 commit cad2909

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,14 @@ Trunk (Unreleased)
356356
HADOOP-9431 TestSecurityUtil#testLocalHostNameForNullOrWild on systems where hostname
357357
contains capital letters (Chris Nauroth via sanjay)
358358

359-
HADOOP-9261 S3n filesystem can move a directory under itself -and so lose data
360-
(fixed in HADOOP-9258) (stevel)
359+
HADOOP-9261 S3n filesystem can move a directory under itself -and so lose data
360+
(fixed in HADOOP-9258) (stevel)
361361

362-
HADOOP-9265 S3 blockstore filesystem breaks part of the Filesystem contract
363-
(fixed in HADOOP-9258) (stevel)
362+
HADOOP-9265 S3 blockstore filesystem breaks part of the Filesystem contract
363+
(fixed in HADOOP-9258) (stevel)
364+
365+
HADOOP-9433 TestLocalFileSystem#testHasFileDescriptor leaks file handle
366+
(Chris Nauroth via sanjay)
364367

365368
OPTIMIZATIONS
366369

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.hadoop.conf.Configuration;
2121
import org.apache.hadoop.fs.FileSystem.Statistics;
22+
import org.apache.hadoop.io.IOUtils;
2223
import org.apache.hadoop.util.Shell;
2324

2425
import static org.apache.hadoop.fs.FileSystemTestHelper.*;
@@ -266,9 +267,14 @@ public void testHasFileDescriptor() throws IOException {
266267
LocalFileSystem fs = FileSystem.getLocal(conf);
267268
Path path = new Path(TEST_ROOT_DIR, "test-file");
268269
writeFile(fs, path, 1);
269-
BufferedFSInputStream bis = new BufferedFSInputStream(
270-
new RawLocalFileSystem().new LocalFSFileInputStream(path), 1024);
271-
assertNotNull(bis.getFileDescriptor());
270+
BufferedFSInputStream bis = null;
271+
try {
272+
bis = new BufferedFSInputStream(new RawLocalFileSystem()
273+
.new LocalFSFileInputStream(path), 1024);
274+
assertNotNull(bis.getFileDescriptor());
275+
} finally {
276+
IOUtils.cleanup(null, bis);
277+
}
272278
}
273279

274280
@Test

0 commit comments

Comments
 (0)