hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject git commit: HADOOP-11179. Java untar should handle the case that the file entry comes without its parent directory entry. Contributed by Craig Welch.
Date Wed, 08 Oct 2014 22:38:44 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 19c307f36 -> f27a88562


HADOOP-11179. Java untar should handle the case that the file entry comes without its parent
directory entry. Contributed by Craig Welch.

(cherry picked from commit a1690519317068d9855174752d22ff45f0e4c962)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f27a8856
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f27a8856
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f27a8856

Branch: refs/heads/branch-2
Commit: f27a88562edfbd0e6e12acb3fb5d29559960aaf4
Parents: 19c307f
Author: Zhijie Shen <zjshen@apache.org>
Authored: Wed Oct 8 15:35:24 2014 -0700
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Wed Oct 8 15:37:57 2014 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt                | 3 +++
 .../src/main/java/org/apache/hadoop/fs/FileUtil.java           | 6 +++---
 .../src/test/java/org/apache/hadoop/fs/TestFileUtil.java       | 6 +++---
 3 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f27a8856/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index e0883aa..fe15cf5 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -611,6 +611,9 @@ Release 2.6.0 - UNRELEASED
     HADOOP-11163. MetricsSystemImpl may miss a registered source.
     (Chuan Liu via cnauroth)
 
+    HADOOP-11179. Java untar should handle the case that the file entry comes
+    without its parent directory entry. (Craig Welch via zjshen)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f27a8856/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
index 8aa8423..2b05293 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
@@ -707,7 +707,7 @@ public class FileUtil {
       TarArchiveEntry entry, File outputDir) throws IOException {
     if (entry.isDirectory()) {
       File subDir = new File(outputDir, entry.getName());
-      if (!subDir.mkdir() && !subDir.isDirectory()) {
+      if (!subDir.mkdirs() && !subDir.isDirectory()) {
         throw new IOException("Mkdirs failed to create tar internal dir "
             + outputDir);
       }
@@ -720,8 +720,8 @@ public class FileUtil {
     }
 
     File outputFile = new File(outputDir, entry.getName());
-    if (!outputDir.exists()) {
-      if (!outputDir.mkdirs()) {
+    if (!outputFile.getParentFile().exists()) {
+      if (!outputFile.getParentFile().mkdirs()) {
         throw new IOException("Mkdirs failed to create tar internal dir "
             + outputDir);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f27a8856/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
index 2234f2f..2a03988 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
@@ -619,7 +619,7 @@ public class TestFileUtil {
     OutputStream os = new FileOutputStream(simpleTar); 
     TarOutputStream tos = new TarOutputStream(os);
     try {
-      TarEntry te = new TarEntry("foo");
+      TarEntry te = new TarEntry("/bar/foo");
       byte[] data = "some-content".getBytes("UTF-8");
       te.setSize(data.length);
       tos.putNextEntry(te);
@@ -634,8 +634,8 @@ public class TestFileUtil {
     // successfully untar it into an existing dir:
     FileUtil.unTar(simpleTar, tmp);
     // check result:
-    assertTrue(new File(tmp, "foo").exists());
-    assertEquals(12, new File(tmp, "foo").length());
+    assertTrue(new File(tmp, "/bar/foo").exists());
+    assertEquals(12, new File(tmp, "/bar/foo").length());
     
     final File regularFile = new File(tmp, "QuickBrownFoxJumpsOverTheLazyDog");
     regularFile.createNewFile();


Mime
View raw message