#12330 make sure the delegate callback has been failed before SendCallback's iteration returns

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2024-10-02 17:06:22 +02:00
parent f8ff191872
commit f71e344766
2 changed files with 1 additions and 43 deletions

View File

@ -17,7 +17,6 @@ import java.util.EventListener;
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;
@ -90,47 +89,6 @@ public abstract class AbstractConnection implements Connection, Invocable
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)}

View File

@ -931,7 +931,7 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
public void onFailure(final Throwable x)
{
Callback callback = resetCallback();
failedCallback(callback, x);
callback.failed(x);
}
@Override