HADOOP-8321. TestUrlStreamHandler fails. (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1331073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-04-26 20:35:58 +00:00
parent d28b982428
commit 17e03547dc
2 changed files with 11 additions and 10 deletions

View File

@ -382,6 +382,8 @@ Release 2.0.0 - UNRELEASED
HADOOP-8310. FileContext#checkPath should handle URIs with no port. (atm) HADOOP-8310. FileContext#checkPath should handle URIs with no port. (atm)
HADOOP-8321. TestUrlStreamHandler fails. (tucu)
BREAKDOWN OF HADOOP-7454 SUBTASKS BREAKDOWN OF HADOOP-7454 SUBTASKS
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh) HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)

View File

@ -17,6 +17,7 @@
*/ */
package org.apache.hadoop.fs; package org.apache.hadoop.fs;
import java.io.IOException;
import java.net.URLStreamHandlerFactory; import java.net.URLStreamHandlerFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -50,25 +51,23 @@ public class FsUrlStreamHandlerFactory implements
private java.net.URLStreamHandler handler; private java.net.URLStreamHandler handler;
public FsUrlStreamHandlerFactory() { public FsUrlStreamHandlerFactory() {
this.conf = new Configuration(); this(new Configuration());
// force the resolution of the configuration files
// this is required if we want the factory to be able to handle
// file:// URLs
this.conf.getClass("fs.file.impl", null);
this.handler = new FsUrlStreamHandler(this.conf);
} }
public FsUrlStreamHandlerFactory(Configuration conf) { public FsUrlStreamHandlerFactory(Configuration conf) {
this.conf = new Configuration(conf); this.conf = new Configuration(conf);
// force the resolution of the configuration files
this.conf.getClass("fs.file.impl", null);
this.handler = new FsUrlStreamHandler(this.conf); this.handler = new FsUrlStreamHandler(this.conf);
} }
public java.net.URLStreamHandler createURLStreamHandler(String protocol) { public java.net.URLStreamHandler createURLStreamHandler(String protocol) {
if (!protocols.containsKey(protocol)) { if (!protocols.containsKey(protocol)) {
boolean known = boolean known = true;
(conf.getClass("fs." + protocol + ".impl", null) != null); try {
FileSystem.getFileSystemClass(protocol, conf);
}
catch (IOException ex) {
known = false;
}
protocols.put(protocol, known); protocols.put(protocol, known);
} }
if (protocols.get(protocol)) { if (protocols.get(protocol)) {