onDone is only called normally _after_ last ack is run, so simplify
@@ -1133,16 +1133,6 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
});
}
@Override public void onEnd(JsonResponse response) throws IOException {
- // Wait for other writers to complete, then write what remains here.
- while ( ! writing.compareAndSet(false, true)) {
- try {
- Thread.sleep(1);
- }
- catch (InterruptedException e) {
- log.log(WARNING, "Interrupted waiting for visited documents to be written; this should not happen");
- Thread.currentThread().interrupt();
- }
- }
for (Runnable write; (write = writes.poll()) != null; write.run());
response.writeArrayEnd();
}
@@ -1161,7 +1151,6 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
callback.onStart(response);
VisitorControlHandler controller = new VisitorControlHandler() {
@Override public void onDone(CompletionCode code, String message) {
- defaultExecutor.execute(() -> {
super.onDone(code, message);
loggingException(() -> {
try (response) {
@@ -1199,7 +1188,6 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
});
phaser.arriveAndAwaitAdvance(); // We may get here while dispatching thread is still putting us in the map.
visits.remove(this).destroy();
- });
}
};
if (parameters.getRemoteDataHandler() == null) {
