HADOOP-7301. FSDataInputStream should expose a getWrappedStream method. Contributed by Jonathan Hsieh

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1124406 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2011-05-18 20:17:16 +00:00
parent d1eaaf30e2
commit 14fd85cdc5
3 changed files with 19 additions and 0 deletions

View File

@ -161,6 +161,9 @@ Trunk (unreleased changes)
HADOOP-7286. Refactor the du/dus/df commands to conform to new FsCommand HADOOP-7286. Refactor the du/dus/df commands to conform to new FsCommand
class. (Daryn Sharp via todd) class. (Daryn Sharp via todd)
HADOOP-7301. FSDataInputStream should expose a getWrappedStream method.
(Jonathan Hsieh via eli)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -64,4 +64,9 @@ public void readFully(long position, byte[] buffer)
public boolean seekToNewSource(long targetPos) throws IOException { public boolean seekToNewSource(long targetPos) throws IOException {
return ((Seekable)in).seekToNewSource(targetPos); return ((Seekable)in).seekToNewSource(targetPos);
} }
// Returns the underlying input stream. This is used by unit tests.
public InputStream getWrappedStream() {
return in;
}
} }

View File

@ -20,6 +20,7 @@
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
@ -1044,6 +1045,16 @@ public void testOutputStreamClosedTwice() throws IOException {
} }
@Test
public void testGetWrappedInputStream() throws IOException {
Path src = getTestRootPath(fSys, "test/hadoop/file");
createFile(src);
FSDataInputStream in = fSys.open(src);
InputStream is = in.getWrappedStream();
in.close();
Assert.assertNotNull(is);
}
protected void createFile(Path path) throws IOException { protected void createFile(Path path) throws IOException {
FileSystemTestHelper.createFile(fSys, path); FileSystemTestHelper.createFile(fSys, path);
} }