Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment for aborting callbacks #11876

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
eb1c9a1
Experiment for aborting callbacks
gregw Jun 4, 2024
860fbd0
Experiment for aborting callbacks
gregw Jun 5, 2024
f4955be
Experiment for aborting callbacks
gregw Jun 5, 2024
0ec0052
add test for legacy wrapping callbacks
lorban Jun 5, 2024
dd4fa07
add test fix in comment
lorban Jun 5, 2024
4661e3c
Experiment for aborting callbacks
gregw Jun 6, 2024
abcc33c
Experiment for aborting callbacks
gregw Jun 6, 2024
bcd888f
Experiment for aborting callbacks
gregw Jun 6, 2024
a80fbc8
Experiment for aborting callbacks
gregw Jun 6, 2024
ad20143
Experiment for aborting callbacks
gregw Jun 6, 2024
46c6b2b
minimal changes to fix IllegalArgumentException in SocketChannel.write()
lorban Jun 6, 2024
81b4227
Experiment for aborting callbacks
gregw Jun 7, 2024
7b54c74
updates from review
gregw Jun 11, 2024
7857422
updates from review
gregw Jun 13, 2024
31fd432
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Jun 13, 2024
01846b9
updates from review
gregw Jun 13, 2024
304aee1
WIP updates from review
gregw Jun 15, 2024
58c3e30
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Jun 15, 2024
dce7956
WIP updates from review
gregw Jun 17, 2024
7099526
WIP updates from review
gregw Jun 17, 2024
10a7a8a
WIP updates from review
gregw Jun 17, 2024
c0beb52
WIP updates from review
gregw Jun 17, 2024
6964fe6
WIP updates from review
gregw Jun 18, 2024
879c341
Calling super.onCompleted() in Callback.Nested subclasses.
sbordet Jun 18, 2024
7798d69
Added TODOs in relevant places where abort needs to be handled.
sbordet Jun 18, 2024
881a450
WIP updates from review
gregw Jun 18, 2024
5da31e7
Merge branch 'jetty-12.0.x' into experiment/jetty-12.0.x/11854/abortC…
gregw Jun 18, 2024
841fefb
WIP updates from review
gregw Jun 18, 2024
c6e3f09
fixed from tests
gregw Jun 18, 2024
4b5d449
fixed tests
gregw Jun 19, 2024
51d6984
fixed Http2Flusher
gregw Jun 19, 2024
1f72dcb
fixed Http2Flusher
gregw Jun 19, 2024
73f1177
WIP
gregw Jun 19, 2024
f1f396c
Temporary fixes for aborting HttpSender.ContentSender
gregw Jun 19, 2024
ca4356e
Better javadoc in ICB
gregw Jun 19, 2024
5cb8f8b
Better javadoc in ICB
gregw Jun 19, 2024
961393e
Fixed ConnectHandler ICB usage
gregw Jun 19, 2024
86b1989
merged from 12.0.x
gregw Jun 24, 2024
bfb91ac
Merge branch 'jetty-12.0.x' into experiment/jetty-12.0.x/11854/abortC…
gregw Jun 25, 2024
1810573
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Jun 27, 2024
0ffd645
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Jun 27, 2024
6b979fd
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Jul 15, 2024
c16059b
Fix ISE handling
gregw Jul 15, 2024
e546948
added onFailure
gregw Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected void doStart() throws Exception
protected void doStop() throws Exception
{
requestTimeouts.destroy();
abort(new AsynchronousCloseException());
abortExchanges(new AsynchronousCloseException());
Sweeper connectionPoolSweeper = client.getBean(Sweeper.class);
if (connectionPoolSweeper != null && connectionPool instanceof Sweeper.Sweepable)
connectionPoolSweeper.remove((Sweeper.Sweepable)connectionPool);
Expand Down Expand Up @@ -294,7 +294,7 @@ public void succeeded()
@Override
public void failed(Throwable x)
{
abort(x);
abortExchanges(x);
}

@Override
Expand Down Expand Up @@ -513,7 +513,7 @@ public boolean remove(Connection connection)
*
* @param cause the abort cause
*/
public void abort(Throwable cause)
private void abortExchanges(Throwable cause)
{
// Copy the queue of exchanges and fail only those that are queued at this moment.
// The application may queue another request from the failure/complete listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.thread.Invocable;

public class ContextResponse extends Response.Wrapper
{
Expand All @@ -33,24 +32,18 @@ public ContextResponse(ContextHandler.ScopedContext context, Request request, Re
@Override
public void write(boolean last, ByteBuffer content, Callback callback)
{
Callback contextCallback = new Callback()
Callback contextCallback = new Callback.Nested(callback)
gregw marked this conversation as resolved.
Show resolved Hide resolved
{
@Override
public void succeeded()
protected void onCompleteSuccess()
{
_context.run(callback::succeeded, getRequest());
}

@Override
public void failed(Throwable x)
protected void onCompleteFailure(Throwable cause)
{
_context.accept(callback::failed, x, getRequest());
}

@Override
public InvocationType getInvocationType()
{
return Invocable.getInvocationType(callback);
_context.accept(callback::failed, cause, getRequest());
}
};
super.write(last, content, contextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ private Runnable lockedFailWrite(Throwable x)
_writeFailure = x;
else
ExceptionUtil.addSuppressedIfNotAssociated(_writeFailure, x);
return () -> HttpChannelState.failed(writeCallback, x);
return () -> HttpChannelState.cancel(writeCallback, x);
}

public long getContentBytesWritten()
Expand Down Expand Up @@ -1916,6 +1916,27 @@ public void onComplianceViolation(ComplianceViolation.Event event)
}
}

/**
* Invoke a callback cancel, handling any {@link Throwable} thrown
* by adding the passed {@code failure} as a suppressed with
* {@link ExceptionUtil#addSuppressedIfNotAssociated(Throwable, Throwable)}.
* @param callback The callback to fail
* @param failure The failure
* @throws RuntimeException If thrown, will have the {@code failure} added as a suppressed.
*/
private static void cancel(Callback callback, Throwable failure)
gregw marked this conversation as resolved.
Show resolved Hide resolved
{
try
{
callback.abort(failure);
}
catch (Throwable t)
{
ExceptionUtil.addSuppressedIfNotAssociated(t, failure);
throw t;
}
}

/**
* Invoke a callback failure, handling any {@link Throwable} thrown
* by adding the passed {@code failure} as a suppressed with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,8 @@ public void succeeded()
{
if (LOG.isDebugEnabled())
LOG.debug("abort due to pending read {} {} ", this, getEndPoint());
abort(new IOException("Pending read in onCompleted"));
Throwable failure = new IOException("Pending read in onCompleted");
getEndPoint().close(failure);
return;
}

Expand Down Expand Up @@ -1603,12 +1604,7 @@ public void failed(Throwable x)
}
if (LOG.isDebugEnabled())
LOG.debug("aborting", x);
abort(x);
}

private void abort(Throwable failure)
{
getEndPoint().close(failure);
getEndPoint().close(x);
}

@Override
Expand Down
Loading
Loading