Author: cutting Date: Wed Feb 28 15:05:53 2007 New Revision: 513049 URL: http://svn.apache.org/viewvc?view=rev&rev=513049 Log: HADOOP-1020. Fix a bug in Path resolution, and with unit tests on Windows.
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/contrib/build-contrib.xml lucene/hadoop/trunk/src/contrib/test/hadoop-site.xml lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestPath.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=513049&r1=513048&r2=513049 ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Wed Feb 28 15:05:53 2007 @@ -165,6 +165,9 @@ 49. HADOOP-940. Improve HDFS's replication scheduling. (Dhruba Borthakur via cutting) +50. HADOOP-1020. Fix a bug in Path resolution, and a with unit tests + on Windows. (cutting) + Release 0.11.2 - 2007-02-16 Modified: lucene/hadoop/trunk/src/contrib/build-contrib.xml URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/build-contrib.xml?view=diff&rev=513049&r1=513048&r2=513049 ============================================================================== --- lucene/hadoop/trunk/src/contrib/build-contrib.xml (original) +++ lucene/hadoop/trunk/src/contrib/build-contrib.xml Wed Feb 28 15:05:53 2007 @@ -140,6 +140,7 @@ <sysproperty key="test.build.data" value="${build.test}/data"/> <sysproperty key="build.test" value="${build.test}"/> + <sysproperty key="contrib.name" value="${name}"/> <!-- requires fork=yes for: relative File paths to use the specified user.dir Modified: lucene/hadoop/trunk/src/contrib/test/hadoop-site.xml URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/test/hadoop-site.xml?view=diff&rev=513049&r1=513048&r2=513049 ============================================================================== --- lucene/hadoop/trunk/src/contrib/test/hadoop-site.xml (original) +++ lucene/hadoop/trunk/src/contrib/test/hadoop-site.xml Wed Feb 28 15:05:53 2007 @@ -14,5 +14,10 @@ <description>A base for other temporary directories.</description> </property> +<property> + <name>mapred.system.dir</name> + <value>build/contrib/${contrib.name}/test/system</value> +</property> + </configuration> Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java?view=diff&rev=513049&r1=513048&r2=513049 ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Path.java Wed Feb 28 15:05:53 2007 @@ -56,23 +56,19 @@ /** Resolve a child path against a parent path. */ public Path(Path parent, Path child) { - if (child.isAbsolute()) { - this.uri = child.uri; - } else { - // Add a slash to parent's path so resolution is compatible with URI's - URI parentUri = parent.uri; - String parentPath = parentUri.getPath(); - if (!(parentPath.equals("/") || parentPath.equals(""))) - try { - parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), - parentUri.getPath()+"/", null, null); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e); - } - URI resolved = parentUri.resolve(child.uri); - initialize(resolved.getScheme(), resolved.getAuthority(), - normalizePath(resolved.getPath())); - } + // Add a slash to parent's path so resolution is compatible with URI's + URI parentUri = parent.uri; + String parentPath = parentUri.getPath(); + if (!(parentPath.equals("/") || parentPath.equals(""))) + try { + parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), + parentUri.getPath()+"/", null, null); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + URI resolved = parentUri.resolve(child.uri); + initialize(resolved.getScheme(), resolved.getAuthority(), + normalizePath(resolved.getPath())); } /** Construct a path from a String. Path strings are URIs, but with Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestPath.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestPath.java?view=diff&rev=513049&r1=513048&r2=513049 ============================================================================== --- lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestPath.java (original) +++ lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestPath.java Wed Feb 28 15:05:53 2007 @@ -136,4 +136,10 @@ assertEquals(new Path("foo/bar/baz","../../../../..").toString(), "../.."); } + public void testScheme() throws java.io.IOException { + assertEquals("foo:/bar", new Path("foo:/","/bar").toString()); + assertEquals("foo://bar/baz", new Path("foo://bar/","/baz").toString()); + } + + }