private void visitAndDelete(HttpRequest request, VisitorParameters parameters, ResponseHandler handler,
                                TestAndSetCondition condition, String route) {
        visitAndProcess(request, parameters, true, handler, route, (id, timestamp, operationParameters) -> {
            DocumentRemove remove = new DocumentRemove(id);
            // If the backend provided a persisted timestamp, we set a condition that specifies _both_ the
            // original selection and the timestamp. If the backend supports timestamp-predicated TaS operations,
            // it will ignore the selection entirely and only look at the timestamp. If it does not, it will fall
            // back to evaluating the selection, which preserves legacy behavior.
            if (timestamp != 0) {
                remove.setCondition(TestAndSetCondition.ofRequiredTimestampWithSelectionFallback(
                        timestamp, condition.getSelection()));
            } else {
                remove.setCondition(condition);
            }
            return asyncSession.remove(remove, operationParameters);
        });
    }
Called at the end of response rendering, before generic status data is written. Called from a dedicated thread pool.
vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java