You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by at...@apache.org on 2011/07/18 09:07:58 UTC

svn commit: r1147762 - in /hadoop/common/trunk/hdfs: CHANGES.txt src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java

Author: atm
Date: Mon Jul 18 07:07:58 2011
New Revision: 1147762

URL: http://svn.apache.org/viewvc?rev=1147762&view=rev
Log:
HDFS-2152. TestWriteConfigurationToDFS causing the random failures. (Uma Maheswara Rao G via atm)

Modified:
    hadoop/common/trunk/hdfs/CHANGES.txt
    hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java

Modified: hadoop/common/trunk/hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/CHANGES.txt?rev=1147762&r1=1147761&r2=1147762&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hdfs/CHANGES.txt Mon Jul 18 07:07:58 2011
@@ -840,6 +840,9 @@ Trunk (unreleased changes)
     HDFS-2120. on reconnect, DN can connect to NN even with different source
     versions. (John George via atm)
 
+    HDFS-2152. TestWriteConfigurationToDFS causing the random failures. (Uma
+    Maheswara Rao G via atm)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java?rev=1147762&r1=1147761&r2=1147762&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java (original)
+++ hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java Mon Jul 18 07:07:58 2011
@@ -20,6 +20,8 @@ package org.apache.hadoop.hdfs;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IOUtils;
+
 import java.io.OutputStream;
 import org.junit.Test;
 
@@ -35,15 +37,25 @@ public class TestWriteConfigurationToDFS
     conf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 4096);
     System.out.println("Setting conf in: " + System.identityHashCode(conf));
     MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
-    FileSystem fs = cluster.getFileSystem();
-    Path filePath = new Path("/testWriteConf.xml");
-    OutputStream os = fs.create(filePath);
-    StringBuilder longString = new StringBuilder();
-    for (int i = 0; i < 100000; i++) {
-      longString.append("hello");
-    } // 500KB
-    conf.set("foobar", longString.toString());
-    conf.writeXml(os);
-    os.close();
+    FileSystem fs = null;
+    OutputStream os = null;
+    try {
+      fs = cluster.getFileSystem();
+      Path filePath = new Path("/testWriteConf.xml");
+      os = fs.create(filePath);
+      StringBuilder longString = new StringBuilder();
+      for (int i = 0; i < 100000; i++) {
+        longString.append("hello");
+      } // 500KB
+      conf.set("foobar", longString.toString());
+      conf.writeXml(os);
+      os.close();
+      os = null;
+      fs.close();
+      fs = null;
+    } finally {
+      IOUtils.cleanup(null, os, fs);
+      cluster.shutdown();
+    }
   }
 }
\ No newline at end of file