Skip to content

Commit

Permalink
Issue #2796 - Max local stream count exceeded when request fails.
Browse files Browse the repository at this point in the history
Updates after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Oct 18, 2018
1 parent ec2b5b1 commit 907e7af
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Expand Up @@ -763,6 +763,7 @@ protected IStream createLocalStream(int streamId)
int localCount = localStreamCount.get();
int maxCount = getMaxLocalStreams();
if (maxCount >= 0 && localCount >= maxCount)
// TODO: remove the dump() in the exception message.
throw new IllegalStateException("Max local stream count " + maxCount + " exceeded" + System.lineSeparator() + dump());
if (localStreamCount.compareAndSet(localCount, localCount + 1))
break;
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.jetty.client.HttpSender;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.IStream;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.frames.ResetFrame;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void release()
connection.release(this);
}

void onStreamClosed(Stream stream)
void onStreamClosed(IStream stream)
{
connection.onStreamClosed(stream, this);
}
Expand Down
Expand Up @@ -35,8 +35,8 @@
import org.eclipse.jetty.client.SendFailure;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.IStream;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
Expand Down Expand Up @@ -94,7 +94,6 @@ protected void release(HttpChannelOverHTTP2 channel)
{
if (LOG.isDebugEnabled())
LOG.debug("Released {}", channel);
// Only non-push channels are released.
if (activeChannels.remove(channel))
{
// Recycle only non-failed channels.
Expand All @@ -109,12 +108,14 @@ protected void release(HttpChannelOverHTTP2 channel)
}
}

void onStreamClosed(Stream stream, HttpChannelOverHTTP2 channel)
void onStreamClosed(IStream stream, HttpChannelOverHTTP2 channel)
{
if (LOG.isDebugEnabled())
LOG.debug("{} closed for {}", stream, channel);
channel.setStream(null);
getHttpDestination().release(this);
// Only non-push channels are released.
if (stream.isLocal())
getHttpDestination().release(this);
}

@Override
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.IStream;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.HeadersFrame;
Expand Down Expand Up @@ -187,7 +188,7 @@ public void onFailure(Stream stream, int error, String reason, Callback callback
@Override
public void onClosed(Stream stream)
{
getHttpChannel().onStreamClosed(stream);
getHttpChannel().onStreamClosed((IStream)stream);
}

private void notifyContent(HttpExchange exchange, DataFrame frame, Callback callback)
Expand Down

0 comments on commit 907e7af

Please sign in to comment.