From 916018a6995978628ce70f2634859fcff0127875 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 8 Dec 2011 20:23:05 +0000 Subject: [PATCH] HADOOP-7870. svn merge -c 1212084 from trunk git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1212086 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 ++- .../apache/hadoop/io/TestSequenceFile.java | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 93347cc5be4..4c2bb9ea188 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -71,7 +71,8 @@ Release 0.23.1 - Unreleased HADOOP-7887. KerberosAuthenticatorHandler is not setting KerberosName name rules from configuration. (tucu) - + HADOOP-7870. fix SequenceFile#createWriter with boolean + createParent arg to respect createParent. (Jon Hsieh via eli) Release 0.23.0 - 2011-11-01 diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java index af0fc3ae1d3..18bc8df6515 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.*; import org.apache.hadoop.fs.*; import org.apache.hadoop.io.SequenceFile.CompressionType; +import org.apache.hadoop.io.SequenceFile.Metadata; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.DefaultCodec; import org.apache.hadoop.util.ReflectionUtils; @@ -516,6 +517,29 @@ public class TestSequenceFile extends TestCase { assertTrue("InputStream for " + path + " should have been closed.", openedFile[0].isClosed()); } + public void testRecursiveSeqFileCreate() throws IOException { + Configuration conf = new Configuration(); + FileSystem fs = FileSystem.getLocal(conf); + Path name = new Path(new Path(System.getProperty("test.build.data","."), + "recursiveCreateDir") , "file"); + boolean createParent = false; + + try { + SequenceFile.createWriter(fs, conf, name, RandomDatum.class, + RandomDatum.class, 512, (short) 1, 4096, createParent, + CompressionType.NONE, null, new Metadata()); + fail("Expected an IOException due to missing parent"); + } catch (IOException ioe) { + // Expected + } + + createParent = true; + SequenceFile.createWriter(fs, conf, name, RandomDatum.class, + RandomDatum.class, 512, (short) 1, 4096, createParent, + CompressionType.NONE, null, new Metadata()); + // should succeed, fails if exception thrown + } + /** For debugging and testing. */ public static void main(String[] args) throws Exception { int count = 1024 * 1024;