Fixed NPEs caused by guard introduced in AbstractFrameBytes's constructor for null callbacks.
This commit is contained in:
parent
9f86d36d6c
commit
04aafcae3c
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||||
import org.eclipse.jetty.spdy.api.Stream;
|
import org.eclipse.jetty.spdy.api.Stream;
|
||||||
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
||||||
|
import org.eclipse.jetty.util.Callback;
|
||||||
|
|
||||||
public class SPDYv3FlowControlStrategy implements FlowControlStrategy
|
public class SPDYv3FlowControlStrategy implements FlowControlStrategy
|
||||||
{
|
{
|
||||||
|
@ -83,7 +84,7 @@ public class SPDYv3FlowControlStrategy implements FlowControlStrategy
|
||||||
if (dataInfo.consumed() == length && !stream.isClosed() && length > 0)
|
if (dataInfo.consumed() == length && !stream.isClosed() && length > 0)
|
||||||
{
|
{
|
||||||
WindowUpdateFrame windowUpdateFrame = new WindowUpdateFrame(session.getVersion(), stream.getId(), length);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
@ -636,7 +637,7 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable
|
||||||
}
|
}
|
||||||
else
|
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
|
@Override
|
||||||
public void run() { callback.succeeded() ; }
|
public void run() { callback.succeeded() ; }
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1139,10 +1140,8 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable
|
||||||
|
|
||||||
protected AbstractFrameBytes(IStream stream, Callback callback)
|
protected AbstractFrameBytes(IStream stream, Callback callback)
|
||||||
{
|
{
|
||||||
if (callback==null)
|
|
||||||
throw new IllegalStateException();
|
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.callback = callback;
|
this.callback = Objects.requireNonNull(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
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.ByteBufferDataInfo;
|
||||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||||
import org.eclipse.jetty.spdy.api.HeadersInfo;
|
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.hamcrest.Matchers.not;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class StandardSessionTest
|
public class StandardSessionTest
|
||||||
|
@ -239,7 +237,7 @@ public class StandardSessionTest
|
||||||
assertThatPushStreamIsHalfClosed(pushStream);
|
assertThatPushStreamIsHalfClosed(pushStream);
|
||||||
assertThatPushStreamIsInSession(pushStream);
|
assertThatPushStreamIsInSession(pushStream);
|
||||||
assertThatStreamIsAssociatedWithPushStream(stream,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);
|
assertThatPushStreamIsClosed(pushStream);
|
||||||
assertThatPushStreamIsNotInSession(pushStream);
|
assertThatPushStreamIsNotInSession(pushStream);
|
||||||
assertThatStreamIsNotAssociatedWithPushStream(stream,pushStream);
|
assertThatStreamIsNotAssociatedWithPushStream(stream,pushStream);
|
||||||
|
@ -328,7 +326,7 @@ public class StandardSessionTest
|
||||||
session.addListener(new TestStreamListener(createdListenerCalledLatch,closedListenerCalledLatch));
|
session.addListener(new TestStreamListener(createdListenerCalledLatch,closedListenerCalledLatch));
|
||||||
IStream stream = createStream();
|
IStream stream = createStream();
|
||||||
IStream pushStream = createPushStream(stream);
|
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",
|
assertThat("onStreamCreated listener has been called twice. Once for the stream and once for the pushStream",
|
||||||
createdListenerCalledLatch.await(5,TimeUnit.SECONDS),is(true));
|
createdListenerCalledLatch.await(5,TimeUnit.SECONDS),is(true));
|
||||||
assertThatOnStreamClosedListenerHasBeenCalled(closedListenerCalledLatch);
|
assertThatOnStreamClosedListenerHasBeenCalled(closedListenerCalledLatch);
|
||||||
|
|
|
@ -182,7 +182,7 @@ public class ResetStreamTest extends AbstractTest
|
||||||
|
|
||||||
Stream stream = session.syn(new SynInfo(false),null).get(5,TimeUnit.SECONDS);
|
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));
|
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));
|
assertThat("stream is reset",rstLatch.await(5,TimeUnit.SECONDS),is(true));
|
||||||
stream.data(new StringDataInfo("2nd dataframe",false),5L,TimeUnit.SECONDS,new Callback.Adapter()
|
stream.data(new StringDataInfo("2nd dataframe",false),5L,TimeUnit.SECONDS,new Callback.Adapter()
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest
|
||||||
@Override
|
@Override
|
||||||
public void succeeded(Stream stream)
|
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());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue