View | Details | Raw Unified | Return to bug 5003
Collapse All | Expand All

(-)orig\PumpStreamHandler.java (-2 / +10 lines)
Lines 106-117 Link Here
106
    }
106
    }
107
107
108
108
109
    static final int TIMEOUT = 300;
110
    
109
    public void stop() {
111
    public void stop() {
110
        try {
112
        try {
111
            inputThread.join();
113
            while (inputThread.isAlive()) {
114
                inputThread.interrupt();
115
                inputThread.join(TIMEOUT);
116
            }
112
        } catch(InterruptedException e) {}
117
        } catch(InterruptedException e) {}
113
        try {
118
        try {
114
            errorThread.join();
119
            while (errorThread.isAlive()) {
120
                errorThread.interrupt();
121
                errorThread.join(TIMEOUT);
122
            }
115
        } catch(InterruptedException e) {}
123
        } catch(InterruptedException e) {}
116
        try {
124
        try {
117
            err.flush();
125
            err.flush();
(-)orig\StreamPumper.java (-8 / +23 lines)
Lines 85-107 Link Here
85
        this.os = os;
84
        this.os = os;
86
    }
85
    }
87
86
88
87
    /**
88
     * read method with possibility to be interrupted, when blocking is set to false
89
     */
90
    public int read(InputStream is, byte[] buf, boolean blocking) throws InterruptedException, IOException {
91
        if (!blocking) {
92
            while (is.available()==0) {
93
                if (Thread.interrupted()) {
94
                    throw new InterruptedException();
95
                }
96
                Thread.sleep(SLEEP);
97
            }
98
        }
99
        return is.read(buf);
100
    }
101
    
89
    /**
102
    /**
90
     * Copies data from the input stream to the output stream.
103
     * Copies data from the input stream to the output stream.
91
     *
104
     *
92
     * Terminates as soon as the input stream is closed or an error occurs.
105
     * Terminates as soon as the input stream is closed or an error occurs (or interrupted on Windows).
93
     */
106
     */
94
    public void run() {
107
    public void run() {
95
        final byte[] buf = new byte[SIZE];
108
        final byte[] buf = new byte[SIZE];
96
109
        // nonblocking read only for Windows solving Ant bug #5003 
110
        boolean blocking = System.getProperty("os.name").toLowerCase().indexOf("windows")<0;
111
        // for other systems use blocking read, because on OS/2 systems with IBM JDK 1.3.x is bug in InputStream.isAvailable()
97
        int length;
112
        int length;
98
        try {
113
        try {
99
            while ((length = is.read(buf)) > 0) {
114
            while ((!Thread.interrupted())&&((length = read(is, buf, blocking)) > 0)) {
100
                os.write(buf, 0, length);
115
                os.write(buf, 0, length);
101
                try {
116
                Thread.sleep(SLEEP);
102
                    Thread.sleep(SLEEP);
103
                } catch (InterruptedException e) {}
104
            }
117
            }
105
        } catch(IOException e) {}
118
        } catch(IOException e) {
119
        } catch (InterruptedException e) {}
106
    }
120
    }
107
}
121
}

Return to bug 5003