hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1063613 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/conf/Configuration.java src/test/core/org/apache/hadoop/conf/TestConfiguration.java
Date Wed, 26 Jan 2011 06:59:14 GMT
Author: todd
Date: Wed Jan 26 06:59:14 2011
New Revision: 1063613

URL: http://svn.apache.org/viewvc?rev=1063613&view=rev
Log:
HADOOP-7118. Fix NPE in Configuration.writeXml. Contributed by Todd Lipcon

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1063613&r1=1063612&r2=1063613&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Wed Jan 26 06:59:14 2011
@@ -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

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=1063613&r1=1063612&r2=1063613&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Wed Jan 26 06:59:14
2011
@@ -1620,6 +1620,7 @@ public class Configuration implements It
     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);

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java?rev=1063613&r1=1063612&r2=1063613&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java Wed Jan
26 06:59:14 2011
@@ -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 class TestConfiguration extends T
     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");



Mime
View raw message