avoiding exception on port auto-detector cancellation

This commit is contained in:
rusefi 2020-07-25 12:55:13 -04:00
parent fa53fe3cc6
commit ec257b8814
1 changed files with 4 additions and 1 deletions

View File

@ -106,6 +106,9 @@ public class IncomingDataBuffer {
return waitForBytes(Timeouts.BINARY_IO_TIMEOUT, loggingMessage, startTimestamp, count);
}
/**
* @return true in case of timeout, false if we have received count of bytes
*/
public boolean waitForBytes(int timeoutMs, String loggingMessage, long startTimestamp, int count) {
log.info(loggingMessage + ": waiting for " + count + " byte(s)");
synchronized (cbb) {
@ -118,7 +121,7 @@ public class IncomingDataBuffer {
try {
cbb.wait(timeout);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
return true; // thread thrown away, handling like a timeout
}
}
}