diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java index ec5862ab0731..5a01abc07935 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.thread.Invocable; import org.eclipse.jetty.util.thread.Invocable.InvocationType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,7 +115,8 @@ public boolean isInterested() public InvocationType getCallbackInvocationType() { Callback callback = _interested.get(); - return Invocable.getInvocationType(callback); + // Identical to Invocable.getInvocationType(callback) except that the cast is costly here. + return callback == null ? InvocationType.BLOCKING : callback.getInvocationType(); } /** diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 0b955ae9a293..56d7b24b84c6 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -25,7 +25,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; @@ -714,11 +716,21 @@ default InvocationType getInvocationType() /** *
A wrapper for {@code Request} instances.
*/ - class Wrapper extends Attributes.Wrapper implements Request + class Wrapper implements Request, Attributes { + /** + * Implementation note: {@link Request.Wrapper} does not extend from {@link Attributes.Wrapper} + * as {@link #getWrapped()} would either need to be implemented as {@code return (Request)getWrapped()} + * which would require a cast from one interface type to another, spoiling the JVM's + * {@code secondary_super_cache}, or by storing the same {@code _wrapped} object in two fields + * (one in {@link Attributes.Wrapper} as type {@link Attributes} and one in {@link Request.Wrapper} as + * type {@link Request}) to save the costly cast from interface type to another. + */ + private final Request _wrapped; + public Wrapper(Request wrapped) { - super(wrapped); + _wrapped = Objects.requireNonNull(wrapped); } @Override @@ -854,9 +866,44 @@ public Session getSession(boolean create) } @Override + public Object removeAttribute(String name) + { + return getWrapped().removeAttribute(name); + } + + @Override + public Object setAttribute(String name, Object attribute) + { + return getWrapped().setAttribute(name, attribute); + } + + @Override + public Object getAttribute(String name) + { + return getWrapped().getAttribute(name); + } + + @Override + public Set