hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject [3/3] hadoop git commit: HADOOP-12479. ProtocMojo does not log the reason for a protoc compilation failure. Contributed by Chris Nauroth.
Date Thu, 15 Oct 2015 22:58:39 GMT
HADOOP-12479. ProtocMojo does not log the reason for a protoc compilation failure. Contributed
by Chris Nauroth.

(cherry picked from commit fdd740622459625efe5e12f37577aa3f5746177f)


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

Branch: refs/heads/branch-2
Commit: adb015847de61d9ae308a7702d091664a907c291
Parents: afa57f1
Author: cnauroth <cnauroth@apache.org>
Authored: Thu Oct 15 15:54:48 2015 -0700
Committer: cnauroth <cnauroth@apache.org>
Committed: Thu Oct 15 15:55:06 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt  |  3 +++
 .../hadoop/maven/plugin/protoc/ProtocMojo.java   |  6 +++++-
 .../apache/hadoop/maven/plugin/util/Exec.java    | 19 ++++++++++++++++++-
 3 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/adb01584/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 50880a3..7bc04ff 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -643,6 +643,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12475. Replace guava Cache with ConcurrentHashMap for caching
     Connection in ipc Client (Walter Su via sjlee)
 
+    HADOOP-12479. ProtocMojo does not log the reason for a protoc compilation
+    failure. (cnauroth)
+
   OPTIMIZATIONS
 
     HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()

http://git-wip-us.apache.org/repos/asf/hadoop/blob/adb01584/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
index b9be33e..0dcac0e 100644
--- a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
@@ -248,11 +248,15 @@ public class ProtocMojo extends AbstractMojo {
 
         exec = new Exec(this);
         out = new ArrayList<String>();
-        if (exec.run(command, out) != 0) {
+        List<String> err = new ArrayList<>();
+        if (exec.run(command, out, err) != 0) {
           getLog().error("protoc compiler error");
           for (String s : out) {
             getLog().error(s);
           }
+          for (String s : err) {
+            getLog().error(s);
+          }
           throw new MojoExecutionException("protoc failure");
         }
         // Write the new checksum file on success.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/adb01584/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
----------------------------------------------------------------------
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
index 37dbc72..ce3543c 100644
--- a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
@@ -42,12 +42,26 @@ public class Exec {
   /**
    * Runs the specified command and saves each line of the command's output to
    * the given list.
-   * 
+   *
    * @param command List containing command and all arguments
    * @param output List in/out parameter to receive command output
    * @return int exit code of command
    */
   public int run(List<String> command, List<String> output) {
+    return this.run(command, output, null);
+  }
+
+  /**
+   * Runs the specified command and saves each line of the command's output to
+   * the given list and each line of the command's stderr to the other list.
+   *
+   * @param command List containing command and all arguments
+   * @param output List in/out parameter to receive command output
+   * @param errors List in/out parameter to receive command stderr
+   * @return int exit code of command
+   */
+  public int run(List<String> command, List<String> output,
+      List<String> errors) {
     int retCode = 1;
     ProcessBuilder pb = new ProcessBuilder(command);
     try {
@@ -66,6 +80,9 @@ public class Exec {
       stdOut.join();
       stdErr.join();
       output.addAll(stdOut.getOutput());
+      if (errors != null) {
+        errors.addAll(stdErr.getOutput());
+      }
     } catch (Exception ex) {
       mojo.getLog().warn(command + " failed: " + ex.toString());
     }


Mime
View raw message