Return permissions before calling listener
In the wild we have seen code which makes new send requests
from ther onCompletion implementation.
When permissions to send are not returned until onComplete
returns, this can lead to deadlock.
Returning permissions earlier removes this possibility
and seems semantically correct to me.
@@ -192,14 +192,11 @@ public class OperationProcessor {
final Result result = process(endpointResult, clusterId);
if (result != null) {
- try {
+ incompleteResultsThrottler.resultReady(result.isSuccess());
resultCallback.onCompletion(result.getDocumentId(), result);
if (traceToStderr && result.hasLocalTrace()) {
System.err.println(result.toString());
}
- } finally {
- incompleteResultsThrottler.resultReady(result.isSuccess());
- }
}
}
public List<Exception> closeClusters() {
