diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java index 90d8c6e677a..cc3b704d772 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java @@ -181,7 +181,10 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction finalListener = ActionListener.wrap( ack -> notifyListeners(request.getJobId(), ack, null), - e -> notifyListeners(request.getJobId(), null, e) + e -> { + notifyListeners(request.getJobId(), null, e); + auditor.error(request.getJobId(), Messages.getMessage(Messages.JOB_AUDIT_DELETING_FAILED, e.getMessage())); + } ); ActionListener markAsDeletingListener = ActionListener.wrap( @@ -192,10 +195,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction { - auditor.error(request.getJobId(), Messages.getMessage(Messages.JOB_AUDIT_DELETING_FAILED, e.getMessage())); - finalListener.onFailure(e); - }); + finalListener::onFailure); ActionListener jobExistsListener = ActionListener.wrap( response -> {