From c9251e5c7369b353d541483a61c1de251d7e47d7 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 3 Jun 2012 22:53:06 +0200 Subject: [PATCH] Fixed bug in AbstractFrameBytes.compareTo(), avoiding NPE when comparing FrameBytes that have a related stream, and those that don't (such as PING). --- .../eclipse/jetty/spdy/StandardSession.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 e2b7a96ee42..bfcbc1e0a09 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 @@ -770,10 +770,10 @@ public class StandardSession implements ISession, Parser.Listener, Handler frameBytes = new ControlFrameBytes<>(stream,handler,context,frame,buffer); + logger.debug("Queuing {} on {}", frame, stream); + ControlFrameBytes frameBytes = new ControlFrameBytes<>(stream, handler, context, frame, buffer); if (timeout > 0) - frameBytes.task = scheduler.schedule(frameBytes,timeout,unit); + frameBytes.task = scheduler.schedule(frameBytes, timeout, unit); // Special handling for PING frames, they must be sent as soon as possible if (ControlFrameType.PING == frame.getType()) @@ -1061,8 +1061,16 @@ public class StandardSession implements ISession, Parser.Listener, Handler that.stream.priority => -1 (this.stream has less priority than that.stream) - return that.getStream().getPriority() - getStream().getPriority(); + // FrameBytes may have or not have a related stream (for example, PING do not have a related stream) + // FrameBytes without related streams have higher priority + IStream thisStream = getStream(); + IStream thatStream = that.getStream(); + if (thisStream == null) + return thatStream == null ? 0 : -1; + if (thatStream == null) + return 1; + // If this.stream.priority > that.stream.priority => this.stream has less priority than that.stream + return thatStream.getPriority() - thisStream.getPriority(); } @Override