The timeout code in WorkQueue.java (I removed some log lines from the
code below for clarity) seems to have an issue if the waitTime is
exactly 0. Looks like it will return the results without closing them if
waitTime is exactly 0.
/**
Use a user-provided policy to decide how long to wait for and
whether to
terminate the call.
*
@param policy
How to decide when to return and to terminate the call.
@return the results, which may or may not be complete and/or closed.
*/
public ClientResult<T> getResults(IResultPolicy<T> policy) {
int callId = callCounter++;
long start = 0;
long waitTime = 0;
while (true) {
synchronized (results) {
// Need to stay synchronized before waitTime() through wait()
or we will
// miss notifications.
waitTime = policy.waitTime(results);
if (waitTime > 0 && !results.isClosed())
else {
break;
}
}
}
if (waitTime < 0) { // shouldn't this be waitTime <= 0 ?
executor.shutdownNow();
results.close();
}
return results;
}
Description
The timeout code in WorkQueue.java (I removed some log lines from the
code below for clarity) seems to have an issue if the waitTime is
exactly 0. Looks like it will return the results without closing them if
waitTime is exactly 0.
/**
Use a user-provided policy to decide how long to wait for and
whether to
terminate the call.
*
@param policy
How to decide when to return and to terminate the call.
@return the results, which may or may not be complete and/or closed.
*/
public ClientResult<T> getResults(IResultPolicy<T> policy) {
int callId = callCounter++;
long start = 0;
long waitTime = 0;
while (true) {
synchronized (results) {
// Need to stay synchronized before waitTime() through wait()
or we will
// miss notifications.
waitTime = policy.waitTime(results);
if (waitTime > 0 && !results.isClosed())