ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs StreamPumper.java
Date Sat, 23 Apr 2005 11:09:15 GMT
jkf         2005/04/23 04:09:15

  Modified:    src/main/org/apache/tools/ant/taskdefs StreamPumper.java
  Log:
  Fixed minor threading issue in StreamPumper
  
  Revision  Changes    Path
  1.24      +11 -11    ant/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java
  
  Index: StreamPumper.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- StreamPumper.java	16 Mar 2005 16:56:03 -0000	1.23
  +++ StreamPumper.java	23 Apr 2005 11:09:15 -0000	1.24
  @@ -34,7 +34,8 @@
       private static final int SIZE = 128;
       private InputStream is;
       private OutputStream os;
  -    private boolean finished;
  +    private volatile boolean finish;
  +    private volatile boolean finished;
       private boolean closeWhenExhausted;
       private boolean autoflush = false;
   
  @@ -68,7 +69,7 @@
        * @param autoflush if true, push through data; if false, let it be buffered
        * @since Ant 1.6.3
        */
  -    /*public*/ void setAutoflush(boolean autoflush) {
  +    /*package*/ void setAutoflush(boolean autoflush) {
           this.autoflush = autoflush;
       }
   
  @@ -78,21 +79,20 @@
        * Terminates as soon as the input stream is closed or an error occurs.
        */
       public void run() {
  -        synchronized (this) {
  -            // Just in case this object is reused in the future
  -            finished = false;
  -        }
  +        finished = false;
  +        finish = false;
   
           final byte[] buf = new byte[SIZE];
   
           int length;
           try {
  -            while ((length = is.read(buf)) > 0 && !finished) {
  +            while ((length = is.read(buf)) > 0 && !finish) {
                   os.write(buf, 0, length);
                   if (autoflush) {
                       os.flush();
                   }
               }
  +            os.flush();
           } catch (Exception e) {
               // ignore errors
           } finally {
  @@ -103,8 +103,8 @@
                       // ignore
                   }
               }
  +            finished = true;
               synchronized (this) {
  -                finished = true;
                   notifyAll();
               }
           }
  @@ -114,7 +114,7 @@
        * Tells whether the end of the stream has been reached.
        * @return true is the stream has been exhausted.
        **/
  -    public synchronized boolean isFinished() {
  +    public boolean isFinished() {
           return finished;
       }
   
  @@ -136,8 +136,8 @@
        * or any byte, and it will be marked as finished.
        * @since Ant 1.6.3
        */
  -    /*public*/ synchronized void stop() {
  -        finished = true;
  +    /*package*/ synchronized void stop() {
  +        finish = true;
           notifyAll();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message