mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reliability in non-blocking mode: before terminating read loop make sure all available output is read
This commit is contained in:
@@ -125,16 +125,21 @@ public abstract class BaseDataReader {
|
||||
|
||||
protected void doRun() {
|
||||
try {
|
||||
boolean stopSignalled = false;
|
||||
while (true) {
|
||||
boolean read = readAvailable();
|
||||
final boolean read = readAvailable();
|
||||
|
||||
if ((!read && isStopped) || mySleepingPolicy == SleepingPolicy.BLOCKING) {
|
||||
// in non-blocking mode, if we have read something on a previous step, we should check
|
||||
// if some additional output is available no matter whether the process is already stopped or not
|
||||
if (stopSignalled || mySleepingPolicy == SleepingPolicy.BLOCKING) {
|
||||
break;
|
||||
}
|
||||
|
||||
TimeoutUtil.sleep(mySleepingPolicy.getTimeToSleep(read));
|
||||
stopSignalled = isStopped;
|
||||
|
||||
if (!stopSignalled) {
|
||||
// if process stopped, there is no sense to sleep,
|
||||
// just check if there is unread output in the stream
|
||||
TimeoutUtil.sleep(mySleepingPolicy.getTimeToSleep(read));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user