HADOOP-7118. Fix NPE in Configuration.writeXml. Contributed by Todd Lipcon
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1063613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
448f8dbb9f
commit
160b6fd496
@ -455,6 +455,8 @@ Release 0.22.0 - Unreleased
|
||||
|
||||
HADOOP-7046. Fix Findbugs warning in Configuration. (Po Cheung via shv)
|
||||
|
||||
HADOOP-7118. Fix NPE in Configuration.writeXml (todd)
|
||||
|
||||
Release 0.21.1 - Unreleased
|
||||
|
||||
IMPROVEMENTS
|
||||
|
@ -1620,6 +1620,7 @@ private synchronized Document asXmlDocument() throws IOException {
|
||||
Element conf = doc.createElement("configuration");
|
||||
doc.appendChild(conf);
|
||||
conf.appendChild(doc.createTextNode("\n"));
|
||||
getProps(); // ensure properties is set
|
||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
||||
String name = (String)e.nextElement();
|
||||
Object object = properties.get(name);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.hadoop.conf;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@ -255,6 +256,16 @@ public void testToString() throws IOException {
|
||||
assertEquals(expectedOutput, conf.toString());
|
||||
}
|
||||
|
||||
public void testWriteXml() throws IOException {
|
||||
Configuration conf = new Configuration();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
conf.writeXml(baos);
|
||||
String result = baos.toString();
|
||||
assertTrue("Result has proper header", result.startsWith(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><configuration>"));
|
||||
assertTrue("Result has proper footer", result.endsWith("</configuration>"));
|
||||
}
|
||||
|
||||
public void testIncludes() throws Exception {
|
||||
tearDown();
|
||||
System.out.println("XXX testIncludes");
|
||||
|
Loading…
Reference in New Issue
Block a user