Skip to content

Commit

Permalink
#12330 make sure the delegate callback has been failed before SendCal…
Browse files Browse the repository at this point in the history
…lback's iteration returns

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Oct 8, 2024
1 parent f8ff191 commit f71e344
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeoutException;

import org.eclipse.jetty.util.Callback;
Expand Down Expand Up @@ -90,47 +89,6 @@ protected Executor getExecutor()
return _executor;
}

protected void failedCallback(final Callback callback, final Throwable x)
{
Runnable failCallback = () ->
{
try
{
callback.failed(x);
}
catch (Exception e)
{
LOG.warn("Failed callback", x);
}
};

switch (Invocable.getInvocationType(callback))
{
case BLOCKING:
try
{
getExecutor().execute(failCallback);
}
catch (RejectedExecutionException e)
{
LOG.debug("Rejected", e);
callback.failed(x);
}
break;

case NON_BLOCKING:
failCallback.run();
break;

case EITHER:
Invocable.invokeNonBlocking(failCallback);
break;

default:
throw new IllegalStateException();
}
}

/**
* <p>Utility method to be called to register read interest.</p>
* <p>After a call to this method, {@link #onFillable()} or {@link #onFillInterestedFailed(Throwable)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ protected void onCompleteSuccess()
public void onFailure(final Throwable x)
{
Callback callback = resetCallback();
failedCallback(callback, x);
callback.failed(x);
}

@Override
Expand Down

0 comments on commit f71e344

Please sign in to comment.