ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r1095736 - in /ant/core/trunk: ./ src/main/org/apache/tools/ant/taskdefs/ src/main/org/apache/tools/ant/util/
Date Thu, 21 Apr 2011 14:57:02 GMT
Author: antoine
Date: Thu Apr 21 14:57:02 2011
New Revision: 1095736

URL: http://svn.apache.org/viewvc?rev=1095736&view=rev
Log:
Exec task may mix the stderr and stdout output while logging it. Bugzilla 50507

Added:
    ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Redirector.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1095736&r1=1095735&r2=1095736&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Thu Apr 21 14:57:02 2011
@@ -353,6 +353,7 @@ Victor Toni
 Vincent Legoll
 Waldek Herka
 Will Wang
+William Bernardet
 William Ferguson
 William Webber
 Wolf Siberski

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1095736&r1=1095735&r2=1095736&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Apr 21 14:57:02 2011
@@ -44,6 +44,9 @@ Fixed bugs:
    It will now fail with a more useful error message.
    Bugzilla Report 51035.
 
+ * Exec task may mix the stderr and stdout output while logging it
+   Bugzilla Report 50507.   
+
 Other changes:
 --------------
 
@@ -62,7 +65,7 @@ Other changes:
  * The expandproperties filter now accepts a nested propertyset
    which, if specified, provides the properties for expansion.
    Bugzilla Report 51044.
-
+   
 Changes from Ant 1.8.1 TO Ant 1.8.2
 ===================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1095736&r1=1095735&r2=1095736&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Apr 21 14:57:02 2011
@@ -1426,6 +1426,10 @@
   </name>
   <name>
     <first>William</first>
+    <last>Bernardet</last>
+  </name>
+  <name>
+    <first>William</first>
     <last>Ferguson</last>
   </name>
   <name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Redirector.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Redirector.java?rev=1095736&r1=1095735&r2=1095736&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Redirector.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Redirector.java Thu Apr 21 14:57:02
2011
@@ -37,6 +37,8 @@ import org.apache.tools.ant.ProjectCompo
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.filters.util.ChainReaderHelper;
+import org.apache.tools.ant.util.LineOrientedOutputStream;
+import org.apache.tools.ant.util.LineOrientedOutputStreamRedirector;
 import org.apache.tools.ant.util.StringUtils;
 import org.apache.tools.ant.util.TeeOutputStream;
 import org.apache.tools.ant.util.ReaderInputStream;
@@ -720,8 +722,8 @@ public class Redirector {
             OutputStreamFunneler funneler = new OutputStreamFunneler(
                     outputStream, funnelTimeout);
             try {
-                outputStream = funneler.getFunnelInstance();
-                errorStream = funneler.getFunnelInstance();
+                outputStream = new LineOrientedOutputStreamRedirector(funneler.getFunnelInstance());
+                errorStream = new LineOrientedOutputStreamRedirector(funneler.getFunnelInstance());
             } catch (IOException eyeOhEx) {
                 throw new BuildException(
                         "error splitting output/error streams", eyeOhEx);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java?rev=1095736&r1=1095735&r2=1095736&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStream.java Thu Apr
21 14:57:02 2011
@@ -66,10 +66,7 @@ public abstract class LineOrientedOutput
      * Flush this log stream
      * @throws IOException if there is an error.
      */
-    public final void flush() throws IOException {
-        if (buffer.size() > 0) {
-            processBuffer();
-        }
+    public void flush() throws IOException {
     }
 
     /**
@@ -97,7 +94,7 @@ public abstract class LineOrientedOutput
      * Writes all remaining
      * @throws IOException if there is an error.
      */
-    public final void close() throws IOException {
+    public void close() throws IOException {
         if (buffer.size() > 0) {
             processBuffer();
         }

Added: ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java?rev=1095736&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
(added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
Thu Apr 21 14:57:02 2011
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+/**
+ * provide a concrete implementation of LineOrientedOutputStream
+ * @since Ant 1.8.3
+ *
+ */
+public class LineOrientedOutputStreamRedirector
+        extends
+            LineOrientedOutputStream {
+    private OutputStream stream;
+    public LineOrientedOutputStreamRedirector(OutputStream stream) {
+        this.stream = stream;
+    }
+    
+    protected void processLine(String line) throws IOException {
+        stream.write((line + System.getProperty("line.separator")).getBytes());
+    }
+    
+    public void close() throws IOException {
+        super.close();
+        stream.close();
+    }
+
+    public void flush() throws IOException {
+        super.flush();
+        stream.flush();
+    }
+}



Mime
View raw message