Repository: hadoop
Updated Branches:
  refs/heads/YARN-3368 97143e966 -> 6b20b8c2c (forced update)


HADOOP-10075. addendum to fix compilation on Windows


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

Branch: refs/heads/YARN-3368
Commit: ebb88231f802918096159da453bed2c4839e6042
Parents: 76a1042
Author: Robert Kanter <rkan...@apache.org>
Authored: Fri Oct 28 17:35:28 2016 -0700
Committer: Robert Kanter <rkan...@apache.org>
Committed: Fri Oct 28 17:35:28 2016 -0700

----------------------------------------------------------------------
 .../maven/plugin/resourcegz/ResourceGzMojo.java | 28 ++++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ebb88231/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/resourcegz/ResourceGzMojo.java
----------------------------------------------------------------------
diff --git 
a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/resourcegz/ResourceGzMojo.java
 
b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/resourcegz/ResourceGzMojo.java
index 5c9e26e..e7ab663 100644
--- 
a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/resourcegz/ResourceGzMojo.java
+++ 
b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/resourcegz/ResourceGzMojo.java
@@ -24,10 +24,12 @@ import org.apache.maven.plugins.annotations.Parameter;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
 import java.util.function.Consumer;
+import java.util.regex.Matcher;
 import java.util.zip.GZIPOutputStream;
 
 /**
@@ -101,17 +103,21 @@ public class ResourceGzMojo extends AbstractMojo {
       }
       try {
         File outFile = new File(outputDir, path.toFile().getCanonicalPath()
-            .replaceFirst(inputDir.getCanonicalPath(), "") + ".gz");
-        outFile.getParentFile().mkdirs();
-        try (
-            GZIPOutputStream os = new GZIPOutputStream(
-                new FileOutputStream(outFile));
-            BufferedReader is = Files.newBufferedReader(path)
-        ) {
-          getLog().info("Compressing " + path + " to " + outFile);
-          IOUtils.copy(is, os);
-        } catch (Throwable t) {
-          this.throwable = t;
+            .replaceFirst(Matcher.quoteReplacement(
+                inputDir.getCanonicalPath()), "") + ".gz");
+        if (outFile.getParentFile().isDirectory() ||
+            outFile.getParentFile().mkdirs()) {
+          try (
+              GZIPOutputStream os = new GZIPOutputStream(
+                  new FileOutputStream(outFile));
+              BufferedReader is = Files.newBufferedReader(path)
+          ) {
+            getLog().info("Compressing " + path + " to " + outFile);
+            IOUtils.copy(is, os);
+          }
+        } else {
+          throw new IOException("Directory " + outFile.getParent()
+              + " does not exist or was unable to be created");
         }
       } catch (Throwable t) {
         this.throwable = t;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to