Improved handling of errors for streams.
This commit is contained in:
parent
05616d1e9d
commit
02454ec8de
|
@ -815,6 +815,8 @@ public abstract class HTTP2Session implements ISession, Parser.Listener
|
|||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
if (stream != null)
|
||||
stream.close();
|
||||
close(ErrorCode.INTERNAL_ERROR, "generator_error", Adapter.INSTANCE);
|
||||
callback.failed(x);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream
|
|||
private final ISession session;
|
||||
private final HeadersFrame frame;
|
||||
private volatile Listener listener;
|
||||
private volatile boolean reset = false;
|
||||
private volatile boolean reset;
|
||||
|
||||
public HTTP2Stream(Scheduler scheduler, ISession session, HeadersFrame frame)
|
||||
{
|
||||
|
@ -131,8 +131,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream
|
|||
|
||||
// The stream is now gone, we must close it to
|
||||
// avoid that its idle timeout is rescheduled.
|
||||
closeState.set(CloseState.CLOSED);
|
||||
onClose();
|
||||
close();
|
||||
|
||||
session.reset(new ResetFrame(getId(), ErrorCode.CANCEL_STREAM_ERROR), disconnectOnFailure);
|
||||
|
||||
|
@ -220,19 +219,15 @@ public class HTTP2Stream extends IdleTimeout implements IStream
|
|||
}
|
||||
case LOCALLY_CLOSED:
|
||||
{
|
||||
if (local)
|
||||
return;
|
||||
if (closeState.compareAndSet(current, CloseState.CLOSED))
|
||||
return;
|
||||
break;
|
||||
if (!local)
|
||||
close();
|
||||
return;
|
||||
}
|
||||
case REMOTELY_CLOSED:
|
||||
{
|
||||
if (!local)
|
||||
return;
|
||||
if (closeState.compareAndSet(current, CloseState.CLOSED))
|
||||
return;
|
||||
break;
|
||||
if (local)
|
||||
close();
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
@ -254,6 +249,13 @@ public class HTTP2Stream extends IdleTimeout implements IStream
|
|||
return windowSize.getAndAdd(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
closeState.set(CloseState.CLOSED);
|
||||
onClose();
|
||||
}
|
||||
|
||||
protected void notifyData(Stream stream, DataFrame frame, Callback callback)
|
||||
{
|
||||
final Listener listener = this.listener;
|
||||
|
|
|
@ -47,4 +47,6 @@ public interface IStream extends Stream
|
|||
public int getWindowSize();
|
||||
|
||||
public int updateWindowSize(int delta);
|
||||
|
||||
public void close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue