Skip to content

Commit dd1514f

Browse files
committed
Merge pull request #99 from jayunit100/escapechars
Escapechars
2 parents 137da7b + 5f28588 commit dd1514f

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterVolume.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
package org.apache.hadoop.fs.glusterfs;
2323

24+
2425
import java.io.File;
2526
import java.io.FileNotFoundException;
2627
import java.io.IOException;
@@ -208,7 +209,8 @@ protected Path getInitialWorkingDirectory() {
208209

209210
public Path fileToPath(File path) {
210211
Enumeration<String> all = volumes.keys();
211-
String rawPath = path.toURI().getRawPath();
212+
String rawPath = path.getAbsolutePath();
213+
212214
String volume = null;
213215
String root = null;
214216

@@ -223,8 +225,7 @@ public Path fileToPath(File path) {
223225

224226
if(default_volume.equalsIgnoreCase(volume))
225227
volume = "";
226-
227-
return new Path("glusterfs://" + volume + "/" + rawPath.substring(root.length()));
228+
return new Path("glusterfs://" + volume + "/" + rawPath.substring(root.length()));
228229
}
229230

230231
public boolean rename(Path src, Path dst) throws IOException {
@@ -292,8 +293,7 @@ public FileStatus[] listStatus(Path f) throws IOException {
292293
results[j] = getFileStatus(fileToPath(names[i]));
293294
j++;
294295
} catch (FileNotFoundException e) {
295-
// ignore the files not found since the dir list may have have changed
296-
// since the names[] list was generated.
296+
log.info("ignoring invisible path : " + names[i]);
297297
}
298298
}
299299
if (j == names.length) {

src/test/java/org/apache/hadoop/fs/test/unit/HcfsFileSystemTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@
3131
import static org.junit.Assert.assertTrue;
3232

3333
import java.io.IOException;
34+
import java.util.Iterator;
3435

36+
import org.apache.hadoop.conf.Configuration;
3537
import org.apache.hadoop.fs.FSDataInputStream;
3638
import org.apache.hadoop.fs.FSDataOutputStream;
3739
import org.apache.hadoop.fs.FileStatus;
3840
import org.apache.hadoop.fs.FileSystem;
41+
import org.apache.hadoop.fs.LocatedFileStatus;
3942
import org.apache.hadoop.fs.Path;
43+
import org.apache.hadoop.fs.RemoteIterator;
4044
import org.apache.hadoop.fs.permission.FsAction;
4145
import org.apache.hadoop.fs.permission.FsPermission;
4246
import org.apache.hadoop.fs.test.connector.HcfsTestConnectorFactory;
@@ -45,7 +49,6 @@
4549
import org.junit.AfterClass;
4650
import org.junit.Assert;
4751
import org.junit.BeforeClass;
48-
import org.junit.Ignore;
4952
import org.junit.Test;
5053

5154
/**
@@ -56,6 +59,26 @@ public class HcfsFileSystemTest{
5659

5760
static FileSystem fs ;
5861

62+
63+
/**
64+
* See MAPREDUCE-5902 for context on why this test is critical
65+
* for ecosystem interoperability.
66+
*/
67+
@org.junit.Test
68+
public void testEncodedPaths() throws Exception {
69+
//FileSystem fs2 = FileSystem.getLocal(new Configuration());
70+
FileSystem fs2 = fs;
71+
Path encodedFiles=new Path("/tmp/encodedTest"+System.currentTimeMillis());
72+
fs2.mkdirs(encodedFiles);
73+
fs2.create(new Path(encodedFiles,"a"));
74+
fs2.create(new Path(encodedFiles,"a%2"));
75+
fs2.create(new Path(encodedFiles,"a%2a"));
76+
fs2.create(new Path(encodedFiles,"a%3a"));
77+
fs2.create(new Path(encodedFiles,"a%4a"));
78+
Assert.assertEquals(5, fs2.listStatus(encodedFiles).length);
79+
fs2.delete(encodedFiles);
80+
}
81+
5982
@BeforeClass
6083
public static void setup() throws Exception {
6184
HcfsTestConnectorInterface connector = HcfsTestConnectorFactory.getHcfsTestConnector();

0 commit comments

Comments
 (0)