Lines 116-122
public class StreamPumper implements Runnable {
Link Here
|
116 |
started = true; |
116 |
started = true; |
117 |
} |
117 |
} |
118 |
finished = false; |
118 |
finished = false; |
119 |
finish = false; |
|
|
120 |
|
119 |
|
121 |
final byte[] buf = new byte[bufferSize]; |
120 |
final byte[] buf = new byte[bufferSize]; |
122 |
|
121 |
|
Lines 130-142
public class StreamPumper implements Runnable {
Link Here
|
130 |
} |
129 |
} |
131 |
|
130 |
|
132 |
length = is.read(buf); |
131 |
length = is.read(buf); |
133 |
if (length <= 0 || finish || Thread.interrupted()) { |
132 |
if (length <= 0 || Thread.interrupted()) { |
134 |
break; |
133 |
break; |
135 |
} |
134 |
} |
136 |
os.write(buf, 0, length); |
135 |
os.write(buf, 0, length); |
137 |
if (autoflush) { |
136 |
if (autoflush) { |
138 |
os.flush(); |
137 |
os.flush(); |
139 |
} |
138 |
} |
|
|
139 |
if (finish) { |
140 |
break; |
141 |
} |
142 |
} |
143 |
// On completion, drain any available data (which might be the first data available for quick executions) |
144 |
if (finish) { |
145 |
while((length = is.available()) > 0) { |
146 |
if (Thread.interrupted()) { |
147 |
break; |
148 |
} |
149 |
length = is.read(buf, 0, Math.min(length, buf.length)); |
150 |
if (length <= 0) { |
151 |
break; |
152 |
} |
153 |
os.write(buf, 0, length); |
154 |
} |
140 |
} |
155 |
} |
141 |
os.flush(); |
156 |
os.flush(); |
142 |
} catch (InterruptedException ie) { |
157 |
} catch (InterruptedException ie) { |
Lines 150-155
public class StreamPumper implements Runnable {
Link Here
|
150 |
FileUtils.close(os); |
165 |
FileUtils.close(os); |
151 |
} |
166 |
} |
152 |
finished = true; |
167 |
finished = true; |
|
|
168 |
finish = false; |
153 |
synchronized (this) { |
169 |
synchronized (this) { |
154 |
notifyAll(); |
170 |
notifyAll(); |
155 |
} |
171 |
} |
156 |
- |
|
|