HDFS-8767. RawLocalFileSystem.listStatus() returns null for UNIX pipefile. Contributed by kanaka kumar avvaru.
This commit is contained in:
parent
0bda84fd48
commit
d96bbe152c
|
@ -987,6 +987,9 @@ Release 2.7.2 - UNRELEASED
|
||||||
HADOOP-12191. Bzip2Factory is not thread safe. (Brahma Reddy Battula
|
HADOOP-12191. Bzip2Factory is not thread safe. (Brahma Reddy Battula
|
||||||
via ozawa)
|
via ozawa)
|
||||||
|
|
||||||
|
HDFS-8767. RawLocalFileSystem.listStatus() returns null for UNIX pipefile.
|
||||||
|
(kanaka kumar avvaru via wheat9)
|
||||||
|
|
||||||
Release 2.7.1 - 2015-07-06
|
Release 2.7.1 - 2015-07-06
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -459,14 +459,8 @@ public class RawLocalFileSystem extends FileSystem {
|
||||||
if (!localf.exists()) {
|
if (!localf.exists()) {
|
||||||
throw new FileNotFoundException("File " + f + " does not exist");
|
throw new FileNotFoundException("File " + f + " does not exist");
|
||||||
}
|
}
|
||||||
if (localf.isFile()) {
|
|
||||||
if (!useDeprecatedFileStatus) {
|
|
||||||
return new FileStatus[] { getFileStatus(f) };
|
|
||||||
}
|
|
||||||
return new FileStatus[] {
|
|
||||||
new DeprecatedRawLocalFileStatus(localf, getDefaultBlockSize(f), this)};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (localf.isDirectory()) {
|
||||||
String[] names = localf.list();
|
String[] names = localf.list();
|
||||||
if (names == null) {
|
if (names == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -477,11 +471,12 @@ public class RawLocalFileSystem extends FileSystem {
|
||||||
try {
|
try {
|
||||||
// Assemble the path using the Path 3 arg constructor to make sure
|
// Assemble the path using the Path 3 arg constructor to make sure
|
||||||
// paths with colon are properly resolved on Linux
|
// paths with colon are properly resolved on Linux
|
||||||
results[j] = getFileStatus(new Path(f, new Path(null, null, names[i])));
|
results[j] = getFileStatus(new Path(f, new Path(null, null,
|
||||||
|
names[i])));
|
||||||
j++;
|
j++;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// ignore the files not found since the dir list may have have changed
|
// ignore the files not found since the dir list may have have
|
||||||
// since the names[] list was generated.
|
// changed since the names[] list was generated.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j == names.length) {
|
if (j == names.length) {
|
||||||
|
@ -490,6 +485,14 @@ public class RawLocalFileSystem extends FileSystem {
|
||||||
return Arrays.copyOf(results, j);
|
return Arrays.copyOf(results, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!useDeprecatedFileStatus) {
|
||||||
|
return new FileStatus[] { getFileStatus(f) };
|
||||||
|
}
|
||||||
|
return new FileStatus[] {
|
||||||
|
new DeprecatedRawLocalFileStatus(localf,
|
||||||
|
getDefaultBlockSize(f), this) };
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean mkOneDir(File p2f) throws IOException {
|
protected boolean mkOneDir(File p2f) throws IOException {
|
||||||
return mkOneDirWithMode(new Path(p2f.getAbsolutePath()), p2f, null);
|
return mkOneDirWithMode(new Path(p2f.getAbsolutePath()), p2f, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,14 @@ import java.util.Random;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.internal.util.reflection.Whitebox;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class tests the local file system via the FileSystem abstraction.
|
* This class tests the local file system via the FileSystem abstraction.
|
||||||
|
@ -612,4 +615,23 @@ public class TestLocalFileSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFileStatusPipeFile() throws Exception {
|
||||||
|
RawLocalFileSystem origFs = new RawLocalFileSystem();
|
||||||
|
RawLocalFileSystem fs = spy(origFs);
|
||||||
|
Configuration conf = mock(Configuration.class);
|
||||||
|
fs.setConf(conf);
|
||||||
|
Whitebox.setInternalState(fs, "useDeprecatedFileStatus", false);
|
||||||
|
Path path = new Path("/foo");
|
||||||
|
File pipe = mock(File.class);
|
||||||
|
when(pipe.isFile()).thenReturn(false);
|
||||||
|
when(pipe.isDirectory()).thenReturn(false);
|
||||||
|
when(pipe.exists()).thenReturn(true);
|
||||||
|
|
||||||
|
FileStatus stat = mock(FileStatus.class);
|
||||||
|
doReturn(pipe).when(fs).pathToFile(path);
|
||||||
|
doReturn(stat).when(fs).getFileStatus(path);
|
||||||
|
FileStatus[] stats = fs.listStatus(path);
|
||||||
|
assertTrue(stats != null && stats.length == 1 && stats[0] == stat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue