HADOOP-8031. Configuration class fails to find embedded .jar resources; should use URL.openStream() (genman via tucu)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1376772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc1fab9084
commit
bbf1f55bee
|
@ -431,6 +431,14 @@ Branch-2 ( Unreleased changes )
|
||||||
HADOOP-4572. Can not access user logs - Jetty is not configured by default
|
HADOOP-4572. Can not access user logs - Jetty is not configured by default
|
||||||
to serve aliases/symlinks (ahmed via tucu)
|
to serve aliases/symlinks (ahmed via tucu)
|
||||||
|
|
||||||
|
HADOOP-8660. TestPseudoAuthenticator failing with NPE. (tucu)
|
||||||
|
|
||||||
|
HADOOP-8699. some common testcases create core-site.xml in test-classes
|
||||||
|
making other testcases to fail. (tucu)
|
||||||
|
|
||||||
|
HADOOP-8031. Configuration class fails to find embedded .jar resources;
|
||||||
|
should use URL.openStream() (genman via tucu)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-3042 SUBTASKS
|
BREAKDOWN OF HDFS-3042 SUBTASKS
|
||||||
|
|
||||||
HADOOP-8220. ZKFailoverController doesn't handle failure to become active
|
HADOOP-8220. ZKFailoverController doesn't handle failure to become active
|
||||||
|
@ -463,11 +471,6 @@ Branch-2 ( Unreleased changes )
|
||||||
|
|
||||||
HADOOP-8405. ZKFC tests leak ZK instances. (todd)
|
HADOOP-8405. ZKFC tests leak ZK instances. (todd)
|
||||||
|
|
||||||
HADOOP-8660. TestPseudoAuthenticator failing with NPE. (tucu)
|
|
||||||
|
|
||||||
HADOOP-8699. some common testcases create core-site.xml in test-classes
|
|
||||||
making other testcases to fail. (tucu)
|
|
||||||
|
|
||||||
Release 2.0.0-alpha - 05-23-2012
|
Release 2.0.0-alpha - 05-23-2012
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -1862,6 +1862,32 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
||||||
return result.entrySet().iterator();
|
return result.entrySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Document parse(DocumentBuilder builder, URL url)
|
||||||
|
throws IOException, SAXException {
|
||||||
|
if (!quietmode) {
|
||||||
|
LOG.info("parsing URL " + url);
|
||||||
|
}
|
||||||
|
if (url == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parse(builder, url.openStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document parse(DocumentBuilder builder, InputStream is)
|
||||||
|
throws IOException, SAXException {
|
||||||
|
if (!quietmode) {
|
||||||
|
LOG.info("parsing input stream " + is);
|
||||||
|
}
|
||||||
|
if (is == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return builder.parse(is);
|
||||||
|
} finally {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadResources(Properties properties,
|
private void loadResources(Properties properties,
|
||||||
ArrayList<Resource> resources,
|
ArrayList<Resource> resources,
|
||||||
boolean quiet) {
|
boolean quiet) {
|
||||||
|
@ -1911,21 +1937,10 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
||||||
boolean returnCachedProperties = false;
|
boolean returnCachedProperties = false;
|
||||||
|
|
||||||
if (resource instanceof URL) { // an URL resource
|
if (resource instanceof URL) { // an URL resource
|
||||||
URL url = (URL)resource;
|
doc = parse(builder, (URL)resource);
|
||||||
if (url != null) {
|
|
||||||
if (!quiet) {
|
|
||||||
LOG.info("parsing " + url);
|
|
||||||
}
|
|
||||||
doc = builder.parse(url.toString());
|
|
||||||
}
|
|
||||||
} else if (resource instanceof String) { // a CLASSPATH resource
|
} else if (resource instanceof String) { // a CLASSPATH resource
|
||||||
URL url = getResource((String)resource);
|
URL url = getResource((String)resource);
|
||||||
if (url != null) {
|
doc = parse(builder, url);
|
||||||
if (!quiet) {
|
|
||||||
LOG.info("parsing " + url);
|
|
||||||
}
|
|
||||||
doc = builder.parse(url.toString());
|
|
||||||
}
|
|
||||||
} else if (resource instanceof Path) { // a file resource
|
} else if (resource instanceof Path) { // a file resource
|
||||||
// Can't use FileSystem API or we get an infinite loop
|
// Can't use FileSystem API or we get an infinite loop
|
||||||
// since FileSystem uses Configuration API. Use java.io.File instead.
|
// since FileSystem uses Configuration API. Use java.io.File instead.
|
||||||
|
@ -1933,22 +1948,13 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
||||||
.getAbsoluteFile();
|
.getAbsoluteFile();
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
LOG.info("parsing " + file);
|
LOG.info("parsing File " + file);
|
||||||
}
|
|
||||||
InputStream in = new BufferedInputStream(new FileInputStream(file));
|
|
||||||
try {
|
|
||||||
doc = builder.parse(in);
|
|
||||||
} finally {
|
|
||||||
in.close();
|
|
||||||
}
|
}
|
||||||
|
doc = parse(builder, new BufferedInputStream(new FileInputStream(file)));
|
||||||
}
|
}
|
||||||
} else if (resource instanceof InputStream) {
|
} else if (resource instanceof InputStream) {
|
||||||
try {
|
doc = parse(builder, (InputStream) resource);
|
||||||
doc = builder.parse((InputStream)resource);
|
returnCachedProperties = true;
|
||||||
returnCachedProperties = true;
|
|
||||||
} finally {
|
|
||||||
((InputStream)resource).close();
|
|
||||||
}
|
|
||||||
} else if (resource instanceof Properties) {
|
} else if (resource instanceof Properties) {
|
||||||
overlay(properties, (Properties)resource);
|
overlay(properties, (Properties)resource);
|
||||||
} else if (resource instanceof Element) {
|
} else if (resource instanceof Element) {
|
||||||
|
|
Loading…
Reference in New Issue