Skip to content

Commit

Permalink
HADOOP-12479. ProtocMojo does not log the reason for a protoc compila…
Browse files Browse the repository at this point in the history
…tion failure. Contributed by Chris Nauroth.
  • Loading branch information
cnauroth committed Oct 15, 2015
1 parent 5f3f0e0 commit fdd7406
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions hadoop-common-project/hadoop-common/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,15 @@ public void execute() throws MojoExecutionException {

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,26 @@ public Exec(Mojo mojo) {
/**
* 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 {
Expand All @@ -66,6 +80,9 @@ public int run(List<String> command, List<String> output) {
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());
}
Expand Down

0 comments on commit fdd7406

Please sign in to comment.