diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java index 8e8ce403b66..c9893d14812 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java @@ -88,6 +88,11 @@ public class StreamResetTest extends AbstractTest stream.reset(resetFrame, Callback.Adapter.INSTANCE); Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS)); + + // Wait a while to let the server remove the + // stream after returning from onReset(). + Thread.sleep(1000); + Stream serverStream = streamRef.get(); Assert.assertEquals(0, serverStream.getSession().getStreams().size()); } diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java index 791aeb18468..210cade784c 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java @@ -84,18 +84,31 @@ public class HttpTransportOverHTTP2 implements HttpTransport { if (commit.compareAndSet(false, true)) { - boolean endStream = !hasContent && lastContent; - commit(info, endStream, sendContent ? commitCallback : callback); + if (sendContent) + { + commit(info, false, commitCallback); + send(content, lastContent, callback); + } + else + { + commit(info, lastContent, callback); + } } else { callback.failed(new IllegalStateException()); } } - - if (sendContent) + else { - send(content, lastContent, callback); + if (sendContent) + { + send(content, lastContent, callback); + } + else + { + callback.succeeded(); + } } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java index a4dfd83bc2b..944cb4267e5 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java @@ -80,7 +80,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa @Override protected boolean needsFill() { - return !changeInterests(SelectionKey.OP_READ, true); + changeInterests(SelectionKey.OP_READ, true); + return false; } @Override @@ -166,14 +167,13 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa } } - private boolean changeInterests(int operation, boolean add) + private void changeInterests(int operation, boolean add) { /** * This method may run concurrently with {@link #updateKey()}. */ boolean pending = false; - boolean changed = true; while (true) { State current = _interestState.get(); @@ -204,20 +204,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa else newInterestOps = oldInterestOps & ~operation; - if (isInputShutdown()) - { - newInterestOps &= ~SelectionKey.OP_READ; - if (add && (operation & SelectionKey.OP_READ) != 0) - changed = false; - } - - if (isOutputShutdown()) - { - newInterestOps &= ~SelectionKey.OP_WRITE; - if (add && (operation & SelectionKey.OP_WRITE) != 0) - changed = false; - } - if (LOG.isDebugEnabled()) LOG.debug("changeInterests pending={} {}->{} for {}", pending, oldInterestOps, newInterestOps, this); @@ -232,8 +218,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa // This must be done after CASing the state above, otherwise the // selector may select and call onSelected() concurrently. submitKeyUpdate(!pending); - - return changed; + return; } default: { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index e942b9daa00..d454fdbaf6e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -266,7 +266,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http finally { setCurrentConnection(last); - if (!suspended && !getEndPoint().isInputShutdown() && getEndPoint().getConnection()==this) + if (!suspended && getEndPoint().isOpen() && getEndPoint().getConnection() == this) { fillInterested(); }