Return-Path: X-Original-To: apmail-flink-commits-archive@minotaur.apache.org Delivered-To: apmail-flink-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 885FF18E50 for ; Fri, 12 Feb 2016 22:04:31 +0000 (UTC) Received: (qmail 70063 invoked by uid 500); 12 Feb 2016 22:04:31 -0000 Delivered-To: apmail-flink-commits-archive@flink.apache.org Received: (qmail 70029 invoked by uid 500); 12 Feb 2016 22:04:31 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 70018 invoked by uid 99); 12 Feb 2016 22:04:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2016 22:04:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 54B17E0A57; Fri, 12 Feb 2016 22:04:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aljoscha@apache.org To: commits@flink.apache.org Message-Id: <996ffe89ff7a4fdf83a014d13a25c97e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: flink git commit: [FLINK-3393] [core] ExternalProcessRunner wait to finish copying error stream Date: Fri, 12 Feb 2016 22:04:31 +0000 (UTC) Repository: flink Updated Branches: refs/heads/master 8b7caaa22 -> 8e55bbd41 [FLINK-3393] [core] ExternalProcessRunner wait to finish copying error stream Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/8e55bbd4 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/8e55bbd4 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/8e55bbd4 Branch: refs/heads/master Commit: 8e55bbd41725cd8c7f29a9e41993a22777ebdacf Parents: 8b7caaa Author: Greg Hogan Authored: Fri Feb 12 08:38:05 2016 -0500 Committer: Aljoscha Krettek Committed: Fri Feb 12 23:04:06 2016 +0100 ---------------------------------------------------------------------- .../java/org/apache/flink/util/ExternalProcessRunner.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/8e55bbd4/flink-core/src/main/java/org/apache/flink/util/ExternalProcessRunner.java ---------------------------------------------------------------------- diff --git a/flink-core/src/main/java/org/apache/flink/util/ExternalProcessRunner.java b/flink-core/src/main/java/org/apache/flink/util/ExternalProcessRunner.java index 8e4725c..b7e388c 100644 --- a/flink-core/src/main/java/org/apache/flink/util/ExternalProcessRunner.java +++ b/flink-core/src/main/java/org/apache/flink/util/ExternalProcessRunner.java @@ -41,6 +41,8 @@ public class ExternalProcessRunner { private final Process process; + private final Thread pipeForwarder; + final StringWriter errorOutput = new StringWriter(); /** @@ -63,7 +65,7 @@ public class ExternalProcessRunner { process = new ProcessBuilder(commandList).start(); - new PipeForwarder(process.getErrorStream(), errorOutput); + pipeForwarder = new PipeForwarder(process.getErrorStream(), errorOutput); } /** @@ -83,6 +85,9 @@ public class ExternalProcessRunner { try { int returnCode = process.waitFor(); + // wait to finish copying standard error stream + pipeForwarder.join(); + if (returnCode != 0) { // determine whether we failed because of a ClassNotFoundException and forward that if (getErrorOutput().toString().contains("Error: Could not find or load main class " + entryPointClassName)) {