diff --git a/server/src/main/java/org/elasticsearch/action/ActionListener.java b/server/src/main/java/org/elasticsearch/action/ActionListener.java index 2c2e460035a35..b3f10a1d88892 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionListener.java +++ b/server/src/main/java/org/elasticsearch/action/ActionListener.java @@ -232,7 +232,33 @@ public String toString() { * @return a listener that listens for responses and invokes the runnable when received */ static ActionListener wrap(Runnable runnable) { - return wrap(r -> runnable.run(), e -> runnable.run()); + return new ActionListener<>() { + @Override + public void onResponse(Response response) { + try { + runnable.run(); + } catch (RuntimeException e) { + assert false : e; + throw e; + } + } + + @Override + public void onFailure(Exception e) { + try { + runnable.run(); + } catch (RuntimeException ex) { + ex.addSuppressed(e); + assert false : ex; + throw ex; + } + } + + @Override + public String toString() { + return "RunnableWrappingActionListener{" + runnable + "}"; + } + }; } /**