diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java index 7ab3ea31760e..83774e328205 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java @@ -551,45 +551,46 @@ interface FailureListener extends RequestListener */ interface Listener extends QueuedListener, BeginListener, HeadersListener, CommitListener, ContentListener, SuccessListener, FailureListener { + @Override + public default void onQueued(Request request) + { + } + + @Override + public default void onBegin(Request request) + { + } + + @Override + public default void onHeaders(Request request) + { + } + + @Override + public default void onCommit(Request request) + { + } + + @Override + public default void onContent(Request request, ByteBuffer content) + { + } + + @Override + public default void onSuccess(Request request) + { + } + + @Override + public default void onFailure(Request request, Throwable failure) + { + } + /** * An empty implementation of {@link Listener} */ class Adapter implements Listener { - @Override - public void onQueued(Request request) - { - } - - @Override - public void onBegin(Request request) - { - } - - @Override - public void onHeaders(Request request) - { - } - - @Override - public void onCommit(Request request) - { - } - - @Override - public void onContent(Request request, ByteBuffer content) - { - } - - @Override - public void onSuccess(Request request) - { - } - - @Override - public void onFailure(Request request, Throwable failure) - { - } } } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java index df6a8d2fe3ec..b16cd7786aff 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java @@ -259,70 +259,77 @@ interface CompleteListener extends ResponseListener */ interface Listener extends BeginListener, HeaderListener, HeadersListener, ContentListener, AsyncContentListener, DemandedContentListener, SuccessListener, FailureListener, CompleteListener { - /** - * An empty implementation of {@link Listener} - */ - class Adapter implements Listener + @Override + public default void onBegin(Response response) { - @Override - public void onBegin(Response response) - { - } + } - @Override - public boolean onHeader(Response response, HttpField field) - { - return true; - } + @Override + public default boolean onHeader(Response response, HttpField field) + { + return true; + } - @Override - public void onHeaders(Response response) - { - } + @Override + public default void onHeaders(Response response) + { + } - @Override - public void onContent(Response response, ByteBuffer content) - { - } + @Override + default void onBeforeContent(Response response, LongConsumer demand) + { + demand.accept(1); + } - @Override - public void onContent(Response response, ByteBuffer content, Callback callback) - { - try - { - onContent(response, content); - callback.succeeded(); - } - catch (Throwable x) - { - callback.failed(x); - } - } + @Override + public default void onContent(Response response, ByteBuffer content) + { + } - @Override - public void onContent(Response response, LongConsumer demand, ByteBuffer content, Callback callback) + @Override + public default void onContent(Response response, ByteBuffer content, Callback callback) + { + try { - onContent(response, content, Callback.from(() -> - { - callback.succeeded(); - demand.accept(1); - }, callback::failed)); + onContent(response, content); + callback.succeeded(); } - - @Override - public void onSuccess(Response response) + catch (Throwable x) { + callback.failed(x); } + } - @Override - public void onFailure(Response response, Throwable failure) + @Override + public default void onContent(Response response, LongConsumer demand, ByteBuffer content, Callback callback) + { + onContent(response, content, Callback.from(() -> { - } + callback.succeeded(); + demand.accept(1); + }, callback::failed)); + } - @Override - public void onComplete(Result result) - { - } + @Override + public default void onSuccess(Response response) + { + } + + @Override + public default void onFailure(Response response, Throwable failure) + { + } + + @Override + public default void onComplete(Result result) + { + } + + /** + * An empty implementation of {@link Listener} + */ + class Adapter implements Listener + { } } }