ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional Javah.java
Date Fri, 13 Jul 2001 12:55:08 GMT
bodewig     01/07/13 05:55:05

  Modified:    src/main/org/apache/tools/ant/taskdefs LogStreamHandler.java
                        PumpStreamHandler.java
               src/main/org/apache/tools/ant/taskdefs/compilers
                        Javac12.java Javac13.java
               src/main/org/apache/tools/ant/taskdefs/optional Javah.java
  Log:
  Make sure streams get flushed and closed - otherwise we may be losing
  messages sent to the logging system, especially on platforms where
  line ends are neither \r nor \n - for example OS/390.
  
  Reported by:	Myron Uecker <uecker@us.ibm.com>
  
  Revision  Changes    Path
  1.3       +12 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
  
  Index: LogStreamHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogStreamHandler.java	2001/01/03 14:18:30	1.2
  +++ LogStreamHandler.java	2001/07/13 12:54:28	1.3
  @@ -54,11 +54,13 @@
   
   package org.apache.tools.ant.taskdefs;
   
  +import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   
   import java.io.OutputStream;
   import java.io.InputStream;
  +import java.io.IOException;
   
   /**
    * Logs standard output and error of a subprocess to the log system of ant.
  @@ -79,4 +81,14 @@
                 new LogOutputStream(task, errlevel));
       }
   
  +    public void stop() {
  +        super.stop();
  +        try {
  +            getErr().close();
  +            getOut().close();
  +        } catch (IOException e) {
  +            // plain impossible
  +            throw new BuildException(e);
  +        }
  +    }
   }
  
  
  
  1.3       +14 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
  
  Index: PumpStreamHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PumpStreamHandler.java	2001/01/03 14:18:31	1.2
  +++ PumpStreamHandler.java	2001/07/13 12:54:30	1.3
  @@ -113,6 +113,20 @@
           try {
               errorThread.join();
           } catch(InterruptedException e) {}
  +        try {
  +            err.flush();
  +        } catch (IOException e) {}
  +        try {
  +            out.flush();
  +        } catch (IOException e) {}
  +    }
  +
  +    protected OutputStream getErr() {
  +        return err;
  +    }
  +
  +    protected OutputStream getOut() {
  +        return out;
       }
   
       protected void createProcessOutputPump(InputStream is, OutputStream os) {
  
  
  
  1.2       +8 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
  
  Index: Javac12.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Javac12.java	2001/01/12 14:08:51	1.1
  +++ Javac12.java	2001/07/13 12:54:43	1.2
  @@ -79,10 +79,10 @@
           attributes.log("Using classic compiler", Project.MSG_VERBOSE);
           Commandline cmd = setupJavacCommand();
   
  +        OutputStream logstr = new LogOutputStream(attributes, Project.MSG_WARN);
           try {
               // Create an instance of the compiler, redirecting output to
               // the project log
  -            OutputStream logstr = new LogOutputStream(attributes, Project.MSG_WARN);
               Class c = Class.forName("sun.tools.javac.Main");
               Constructor cons = c.getConstructor(new Class[] { OutputStream.class, String.class
});
               Object compiler = cons.newInstance(new Object[] { logstr, "javac" });
  @@ -102,6 +102,13 @@
                   throw (BuildException) ex;
               } else {
                   throw new BuildException("Error starting classic compiler: ", ex, location);
  +            }
  +        } finally {
  +            try {
  +                logstr.close();
  +            } catch (IOException e) {
  +                // plain impossible
  +                throw new BuildException(e);
               }
           }
       }
  
  
  
  1.2       +3 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
  
  Index: Javac13.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Javac13.java	2001/01/12 14:08:51	1.1
  +++ Javac13.java	2001/07/13 12:54:45	1.2
  @@ -86,10 +86,10 @@
           PrintStream err = System.err;
           PrintStream out = System.out;
   
  +        PrintStream logstr = 
  +            new PrintStream(new LogOutputStream(attributes, Project.MSG_WARN));
           // Use reflection to be able to build on all JDKs >= 1.1:
           try {
  -            PrintStream logstr = 
  -                new PrintStream(new LogOutputStream(attributes, Project.MSG_WARN));
               System.setOut(logstr);
               System.setErr(logstr);
               Class c = Class.forName ("com.sun.tools.javac.Main");
  @@ -108,6 +108,7 @@
           } finally {
               System.setErr(err);
               System.setOut(out);
  +            logstr.close();
           }
       }
   }
  
  
  
  1.5       +3 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  
  Index: Javah.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Javah.java	2001/07/07 13:51:12	1.4
  +++ Javah.java	2001/07/13 12:55:00	1.5
  @@ -311,14 +311,14 @@
           PrintStream err = System.err;
           PrintStream out = System.out;
   
  +        PrintStream logstr = 
  +            new PrintStream(new LogOutputStream(this, Project.MSG_WARN));
           try {
               // Javac uses logstr to change the output stream and calls
               // the constructor's invoke method to create a compiler instance
               // dynamically. However, javah has a different interface and this
               // makes it harder, so here's a simple alternative.
               //------------------------------------------------------------------
  -            PrintStream logstr = 
  -                new PrintStream(new LogOutputStream(this, Project.MSG_WARN));
               System.setOut(logstr);
               System.setErr(logstr);
               com.sun.tools.javah.Main main = new com.sun.tools.javah.Main( cmd.getArguments()
);
  @@ -338,6 +338,7 @@
           } finally {
               System.setErr(err);
               System.setOut(out);
  +            logstr.close();
           }
       }
   
  
  
  

Mime
View raw message