HADOOP-8440. HarFileSystem.decodeHarURI fails for URIs whose host contains numbers. Contributed by Ivan Mitic.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1501424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31fff48ec4
commit
9b252b39df
@ -798,6 +798,9 @@ Release 2.1.0-beta - 2013-07-02
|
|||||||
HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather
|
HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather
|
||||||
than throw EOF at end of file. (Zhijie Shen via acmurthy)
|
than throw EOF at end of file. (Zhijie Shen via acmurthy)
|
||||||
|
|
||||||
|
HADOOP-8440. HarFileSystem.decodeHarURI fails for URIs whose host contains
|
||||||
|
numbers. (Ivan Mitic via cnauroth)
|
||||||
|
|
||||||
Release 2.0.5-alpha - 06/06/2013
|
Release 2.0.5-alpha - 06/06/2013
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -204,35 +204,36 @@ private URI decodeHarURI(URI rawURI, Configuration conf) throws IOException {
|
|||||||
//create a path
|
//create a path
|
||||||
return FileSystem.getDefaultUri(conf);
|
return FileSystem.getDefaultUri(conf);
|
||||||
}
|
}
|
||||||
String host = rawURI.getHost();
|
String authority = rawURI.getAuthority();
|
||||||
if (host == null) {
|
if (authority == null) {
|
||||||
throw new IOException("URI: " + rawURI
|
throw new IOException("URI: " + rawURI
|
||||||
+ " is an invalid Har URI since host==null."
|
+ " is an invalid Har URI since authority==null."
|
||||||
+ " Expecting har://<scheme>-<host>/<path>.");
|
+ " Expecting har://<scheme>-<host>/<path>.");
|
||||||
}
|
}
|
||||||
int i = host.indexOf('-');
|
|
||||||
|
int i = authority.indexOf('-');
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
throw new IOException("URI: " + rawURI
|
throw new IOException("URI: " + rawURI
|
||||||
+ " is an invalid Har URI since '-' not found."
|
+ " is an invalid Har URI since '-' not found."
|
||||||
+ " Expecting har://<scheme>-<host>/<path>.");
|
+ " Expecting har://<scheme>-<host>/<path>.");
|
||||||
}
|
}
|
||||||
final String underLyingScheme = host.substring(0, i);
|
|
||||||
i++;
|
|
||||||
final String underLyingHost = i == host.length()? null: host.substring(i);
|
|
||||||
int underLyingPort = rawURI.getPort();
|
|
||||||
String auth = (underLyingHost == null && underLyingPort == -1)?
|
|
||||||
null:(underLyingHost+
|
|
||||||
(underLyingPort == -1 ? "" : ":"+underLyingPort));
|
|
||||||
URI tmp = null;
|
|
||||||
if (rawURI.getQuery() != null) {
|
if (rawURI.getQuery() != null) {
|
||||||
// query component not allowed
|
// query component not allowed
|
||||||
throw new IOException("query component in Path not supported " + rawURI);
|
throw new IOException("query component in Path not supported " + rawURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
URI tmp = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tmp = new URI(underLyingScheme, auth, rawURI.getPath(),
|
// convert <scheme>-<host> to <scheme>://<host>
|
||||||
rawURI.getQuery(), rawURI.getFragment());
|
URI baseUri = new URI(authority.replaceFirst("-", "://"));
|
||||||
|
|
||||||
|
tmp = new URI(baseUri.getScheme(), baseUri.getAuthority(),
|
||||||
|
rawURI.getPath(), rawURI.getQuery(), rawURI.getFragment());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
// do nothing should not happen
|
throw new IOException("URI: " + rawURI
|
||||||
|
+ " is an invalid Har URI. Expecting har://<scheme>-<host>/<path>.");
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ public void testHarUri() {
|
|||||||
checkInvalidPath("har://hdfs/foo.har", conf);
|
checkInvalidPath("har://hdfs/foo.har", conf);
|
||||||
checkInvalidPath("har://-hdfs/foo.har", conf);
|
checkInvalidPath("har://-hdfs/foo.har", conf);
|
||||||
checkInvalidPath("har://-/foo.har", conf);
|
checkInvalidPath("har://-/foo.har", conf);
|
||||||
|
checkInvalidPath("har://127.0.0.1-/foo.har", conf);
|
||||||
|
checkInvalidPath("har://127.0.0.1/foo.har", conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkInvalidPath(String s, Configuration conf) {
|
static void checkInvalidPath(String s, Configuration conf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user