diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java index 8517f5942c6..e456d7e1c76 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.frames.WindowUpdateFrame; +import org.eclipse.jetty.util.Callback; public class SPDYv3FlowControlStrategy implements FlowControlStrategy { @@ -83,7 +84,7 @@ public class SPDYv3FlowControlStrategy implements FlowControlStrategy if (dataInfo.consumed() == length && !stream.isClosed() && length > 0) { WindowUpdateFrame windowUpdateFrame = new WindowUpdateFrame(session.getVersion(), stream.getId(), length); - session.control(stream, windowUpdateFrame, 0, TimeUnit.MILLISECONDS, null); + session.control(stream, windowUpdateFrame, 0, TimeUnit.MILLISECONDS, new Callback.Adapter()); } } } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java index 573fa220184..bd97876f104 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -636,7 +637,7 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable } else { - control(null, frame, 0, TimeUnit.MILLISECONDS, null); + control(null, frame, 0, TimeUnit.MILLISECONDS, new Callback.Adapter()); } } @@ -1110,7 +1111,7 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable @Override public void run() { callback.succeeded() ; } }); - + } @Override @@ -1139,10 +1140,8 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable protected AbstractFrameBytes(IStream stream, Callback callback) { - if (callback==null) - throw new IllegalStateException(); this.stream = stream; - this.callback = callback; + this.callback = Objects.requireNonNull(callback); } @Override diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java index 592123439a0..5341b87b5c0 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java @@ -29,7 +29,6 @@ import java.util.concurrent.TimeoutException; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool; -import org.eclipse.jetty.spdy.StandardSession.FrameBytes; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.HeadersInfo; @@ -65,10 +64,9 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doAnswer; @RunWith(MockitoJUnitRunner.class) public class StandardSessionTest @@ -239,7 +237,7 @@ public class StandardSessionTest assertThatPushStreamIsHalfClosed(pushStream); assertThatPushStreamIsInSession(pushStream); assertThatStreamIsAssociatedWithPushStream(stream,pushStream); - session.data(pushStream,new StringDataInfo("close",true),5,TimeUnit.SECONDS,null); + session.data(pushStream,new StringDataInfo("close",true),5,TimeUnit.SECONDS,new Callback.Adapter()); assertThatPushStreamIsClosed(pushStream); assertThatPushStreamIsNotInSession(pushStream); assertThatStreamIsNotAssociatedWithPushStream(stream,pushStream); @@ -328,7 +326,7 @@ public class StandardSessionTest session.addListener(new TestStreamListener(createdListenerCalledLatch,closedListenerCalledLatch)); IStream stream = createStream(); IStream pushStream = createPushStream(stream); - session.data(pushStream,new StringDataInfo("close",true),5,TimeUnit.SECONDS,null); + session.data(pushStream,new StringDataInfo("close",true),5,TimeUnit.SECONDS,new Callback.Adapter()); assertThat("onStreamCreated listener has been called twice. Once for the stream and once for the pushStream", createdListenerCalledLatch.await(5,TimeUnit.SECONDS),is(true)); assertThatOnStreamClosedListenerHasBeenCalled(closedListenerCalledLatch); diff --git a/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/ResetStreamTest.java b/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/ResetStreamTest.java index 087435f08a9..db801d568bc 100644 --- a/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/ResetStreamTest.java +++ b/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/ResetStreamTest.java @@ -182,7 +182,7 @@ public class ResetStreamTest extends AbstractTest Stream stream = session.syn(new SynInfo(false),null).get(5,TimeUnit.SECONDS); assertThat("syn is received by server", synLatch.await(5,TimeUnit.SECONDS),is(true)); - stream.data(new StringDataInfo("data",false),5,TimeUnit.SECONDS,null); + stream.data(new StringDataInfo("data",false),5,TimeUnit.SECONDS,new Callback.Adapter()); assertThat("stream is reset",rstLatch.await(5,TimeUnit.SECONDS),is(true)); stream.data(new StringDataInfo("2nd dataframe",false),5L,TimeUnit.SECONDS,new Callback.Adapter() { diff --git a/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/SynDataReplyDataLoadTest.java b/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/SynDataReplyDataLoadTest.java index ea1f324ff5a..e1429aa2281 100644 --- a/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/SynDataReplyDataLoadTest.java +++ b/jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/SynDataReplyDataLoadTest.java @@ -178,7 +178,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest @Override public void succeeded(Stream stream) { - stream.data(new StringDataInfo("data_" + stream.getId(), true), 0, TimeUnit.SECONDS, null); + stream.data(new StringDataInfo("data_" + stream.getId(), true), 0, TimeUnit.SECONDS, new Callback.Adapter()); } }); }