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

(-)src\main\org\apache\tools\ant\taskdefs\StreamPumper.java (-8 / +20 lines)
Lines 85-107 Link Here
85
        this.os = os;
85
        this.os = os;
86
    }
86
    }
87
87
88
88
    /**
89
     * read method with possibility to be interrupted, when blocking is set to false
90
     */
91
    public int read(InputStream is, byte[] buf, boolean blocking) throws InterruptedException, IOException {
92
        if (!blocking) {
93
            while (is.available()==0) {
94
                Thread.sleep(SLEEP);
95
            }
96
        }
97
        return is.read(buf);
98
    }
99
    
89
    /**
100
    /**
90
     * Copies data from the input stream to the output stream.
101
     * Copies data from the input stream to the output stream.
91
     *
102
     *
92
     * Terminates as soon as the input stream is closed or an error occurs.
103
     * Terminates as soon as the input stream is closed or an error occurs (or interrupted on Windows).
93
     */
104
     */
94
    public void run() {
105
    public void run() {
95
        final byte[] buf = new byte[SIZE];
106
        final byte[] buf = new byte[SIZE];
96
107
        // nonblocking read only for Windows solving Ant bug #5003 
108
        boolean blocking = System.getProperty("os.name").toLowerCase().indexOf("windows")<0;
109
        // 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;
110
        int length;
98
        try {
111
        try {
99
            while ((length = is.read(buf)) > 0) {
112
            while ((!Thread.currentThread().isInterrupted())&&((length = read(is, buf, blocking)) > 0)) {
100
                os.write(buf, 0, length);
113
                os.write(buf, 0, length);
101
                try {
114
                Thread.sleep(SLEEP);
102
                    Thread.sleep(SLEEP);
103
                } catch (InterruptedException e) {}
104
            }
115
            }
105
        } catch(IOException e) {}
116
        } catch(IOException e) {
117
        } catch (InterruptedException e) {}
106
    }
118
    }
107
}
119
}
(-)src\main\org\apache\tools\ant\taskdefs\PumpStreamHandler.java (+2 lines)
Lines 107-115 Link Here
107
107
108
108
109
    public void stop() {
109
    public void stop() {
110
        inputThread.interrupt();
110
        try {
111
        try {
111
            inputThread.join();
112
            inputThread.join();
112
        } catch(InterruptedException e) {}
113
        } catch(InterruptedException e) {}
114
        errorThread.interrupt();
113
        try {
115
        try {
114
            errorThread.join();
116
            errorThread.join();
115
        } catch(InterruptedException e) {}
117
        } catch(InterruptedException e) {}

Return to bug 5003