Future timeout does not cancel running task
It appears that SDCri heavily uses Futures and accessing their results by means of get()
with timeout. Unfortunately, a timeout does not cancel the task:
if (s <= COMPLETING &&
(s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
throw new TimeoutException();
return report(s);
From this it follows that for some occurrences in SDCri catching a TimeoutException needs to explicitly cancel the future to not continue running a task for which side effects may ensue. Example:
try {
future.set(connect(discoveredDevice).get(maxWaitForFutures.toMillis(), TimeUnit.MILLISECONDS));
} catch (TimeoutException e) {
future.cancel(true);
// ...
}
Seek all occurrences of Future.get()
with timeout, check if a timeout needs to cancel the task and fix accordingly.