Guarded against NPE if the channel is not associated with the stream.

This commit is contained in:
Simone Bordet 2016-10-27 16:45:12 +02:00
parent 8fef113372
commit 5ad8f2a777
2 changed files with 13 additions and 7 deletions

View File

@ -140,15 +140,18 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Processing {} on {}", frame, stream); LOG.debug("Processing {} on {}", frame, stream);
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE); HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
Runnable task = channel.onRequestContent(frame, callback); if (channel != null)
if (task != null) {
offerTask(task, false); Runnable task = channel.onRequestContent(frame, callback);
if (task != null)
offerTask(task, false);
}
} }
public boolean onStreamTimeout(IStream stream, Throwable failure) public boolean onStreamTimeout(IStream stream, Throwable failure)
{ {
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE); HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
boolean result = channel.onStreamTimeout(failure); boolean result = channel != null && channel.onStreamTimeout(failure);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", stream, failure); LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", stream, failure);
return result; return result;
@ -159,7 +162,8 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Processing failure on {}: {}", stream, failure); LOG.debug("Processing failure on {}: {}", stream, failure);
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE); HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
channel.onFailure(failure); if (channel != null)
channel.onFailure(failure);
} }
public boolean onSessionTimeout(Throwable failure) public boolean onSessionTimeout(Throwable failure)
@ -169,7 +173,8 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
for (Stream stream : session.getStreams()) for (Stream stream : session.getStreams())
{ {
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE); HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
result &= !channel.isRequestHandled(); if (channel != null)
result &= !channel.isRequestHandled();
} }
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", session, failure); LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", session, failure);

View File

@ -215,7 +215,8 @@ public class HttpTransportOverHTTP2 implements HttpTransport
// Consume the existing queued data frames to // Consume the existing queued data frames to
// avoid stalling the session flow control. // avoid stalling the session flow control.
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE); HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
channel.consumeInput(); if (channel != null)
channel.consumeInput();
} }
@Override @Override