File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed
server/src/main/java/org/elasticsearch/action Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 2828import java .util .function .Consumer ;
2929import java .util .function .Function ;
3030
31+ import static org .elasticsearch .action .ActionListenerImplementations .checkedRunnableFromReleasable ;
3132import static org .elasticsearch .action .ActionListenerImplementations .runnableFromReleasable ;
3233import static org .elasticsearch .action .ActionListenerImplementations .safeAcceptException ;
3334import static org .elasticsearch .action .ActionListenerImplementations .safeOnFailure ;
@@ -340,18 +341,9 @@ static <Response> ActionListener<Response> runBefore(ActionListener<Response> de
340341 * resource before the listener is notified via either {@code #onResponse} or {@code #onFailure}.
341342 */
342343 static <Response > ActionListener <Response > releaseBefore (ActionListener <Response > delegate , Releasable releaseBefore ) {
343- Runnable releasableRunnable = runnableFromReleasable (releaseBefore );
344- return assertOnce (new ActionListenerImplementations .RunBeforeActionListener <>(delegate , new CheckedRunnable <>() {
345- @ Override
346- public void run () {
347- releasableRunnable .run ();
348- }
349-
350- @ Override
351- public String toString () {
352- return releasableRunnable .toString ();
353- }
354- }));
344+ return assertOnce (
345+ new ActionListenerImplementations .RunBeforeActionListener <>(delegate , checkedRunnableFromReleasable (releaseBefore ))
346+ );
355347 }
356348
357349 /**
Original file line number Diff line number Diff line change @@ -58,6 +58,20 @@ public String toString() {
5858 };
5959 }
6060
61+ static CheckedRunnable <Exception > checkedRunnableFromReleasable (Releasable releasable ) {
62+ return new CheckedRunnable <>() {
63+ @ Override
64+ public void run () {
65+ Releasables .closeExpectNoException (releasable );
66+ }
67+
68+ @ Override
69+ public String toString () {
70+ return "release[" + releasable + "]" ;
71+ }
72+ };
73+ }
74+
6175 static void safeAcceptException (Consumer <Exception > consumer , Exception e ) {
6276 assert e != null ;
6377 try {
You can’t perform that action at this time.
0 commit comments