From eaa0638c12d46f1e4a73838214dff52336a3dcd6 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Mon, 18 Jul 2011 07:07:58 +0000 Subject: [PATCH] HDFS-2152. TestWriteConfigurationToDFS causing the random failures. (Uma Maheswara Rao G via atm) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1147762 13f79535-47bb-0310-9956-ffa450edef68 --- hdfs/CHANGES.txt | 3 ++ .../hdfs/TestWriteConfigurationToDFS.java | 32 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hdfs/CHANGES.txt b/hdfs/CHANGES.txt index 91e49be8288..92f7b54a545 100644 --- a/hdfs/CHANGES.txt +++ b/hdfs/CHANGES.txt @@ -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 diff --git a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java index aacaad9d521..68c593b2e86 100644 --- a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java +++ b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestWriteConfigurationToDFS.java @@ -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