HADOOP-15948. Inconsistency in get and put syntax if filename/dirname contains space. Contributed by Ayush Saxena.

(cherry picked from commit 23b441c225)
This commit is contained in:
Vinayakumar B 2018-11-26 18:11:01 +05:30
parent f94d40341f
commit 07529a209d
2 changed files with 11 additions and 6 deletions

View File

@ -268,12 +268,7 @@ class CopyCommands {
try { try {
items.add(new PathData(new URI(arg), getConf())); items.add(new PathData(new URI(arg), getConf()));
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
if (Path.WINDOWS) { items.add(new PathData(arg, getConf()));
// Unlike URI, PathData knows how to parse Windows drive-letter paths.
items.add(new PathData(arg, getConf()));
} else {
throw new IOException("unexpected URISyntaxException", e);
}
} }
return items; return items;
} }

View File

@ -43,9 +43,11 @@ public class TestCopyPreserveFlag {
private static final int MODIFICATION_TIME = 12345000; private static final int MODIFICATION_TIME = 12345000;
private static final int ACCESS_TIME = 23456000; private static final int ACCESS_TIME = 23456000;
private static final Path DIR_FROM = new Path("d0"); private static final Path DIR_FROM = new Path("d0");
private static final Path DIR_FROM_SPL = new Path("d0 space");
private static final Path DIR_TO1 = new Path("d1"); private static final Path DIR_TO1 = new Path("d1");
private static final Path DIR_TO2 = new Path("d2"); private static final Path DIR_TO2 = new Path("d2");
private static final Path FROM = new Path(DIR_FROM, "f0"); private static final Path FROM = new Path(DIR_FROM, "f0");
private static final Path FROM_SPL = new Path(DIR_FROM_SPL, "f0");
private static final Path TO = new Path(DIR_TO1, "f1"); private static final Path TO = new Path(DIR_TO1, "f1");
private static final FsPermission PERMISSIONS = new FsPermission( private static final FsPermission PERMISSIONS = new FsPermission(
FsAction.ALL, FsAction.ALL,
@ -120,6 +122,14 @@ public class TestCopyPreserveFlag {
assertAttributesChanged(TO); assertAttributesChanged(TO);
} }
@Test(timeout = 10000)
public void testPutWithSplCharacter() throws Exception {
fs.mkdirs(DIR_FROM_SPL);
fs.createNewFile(FROM_SPL);
run(new Put(), FROM_SPL.toString(), TO.toString());
assertAttributesChanged(TO);
}
@Test(timeout = 10000) @Test(timeout = 10000)
public void testCopyFromLocal() throws Exception { public void testCopyFromLocal() throws Exception {
run(new CopyFromLocal(), FROM.toString(), TO.toString()); run(new CopyFromLocal(), FROM.toString(), TO.toString());