hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Kubes <ku...@apache.org>
Subject Path Handling and URIs
Date Wed, 14 Nov 2007 22:34:38 GMT
I can't really tell if this is a bug or a *feature*.  Path is meant to 
handle various file systems, DFS, S3, Local, etc.  Path has a toURI 
method.  I don't think the current behavior of toURI is consistent, 
especially with local file handling.  Take the following code:

Path path = new Path("/home/dennis");
URI uri = new File("/home/dennis").toURI();
URI straight = new URI("/home/dennis");
// this will error out for not being absolute File fromStraight = new 
File(straight);

System.out.println("Path to URI: " + path.toUri());
System.out.println("Path to String: " + path.toString());
System.out.println("URI from File: " + uri);
System.out.println("URI straight: " + straight);

Prints

Path to URI: /home/dennis
Path to String: /home/dennis
URI from File: file:/home/dennis/
URI straight: /home/dennis

If I call Path.toURI is essentially prints out the path without a 
scheme.  On the other hand if I create a file and call its toURI method 
I get a scheme.  If I try to create a URI without a scheme, the code 
errors out for not being an absolute path.

My question here is shouldn't the Path toURI method always return the 
full path with the scheme?  The current behavior causes problems on 
local file system handling code, such as search servers in Nutch.  I can 
of course write workarounds for the current behavior but I believe there 
is a larger issue here.  All thoughts are appreciated.

Dennis Kubes


Mime
View raw message