Revert "Ensure we only call debugData.release() if we called debugData.retain()"
This reverts commit 4beb075dd3
.
This commit is contained in:
parent
2c4a7a2539
commit
3c62a20519
@ -670,7 +670,6 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
|||||||
@Override
|
@Override
|
||||||
public ChannelFuture goAway(final ChannelHandlerContext ctx, final int lastStreamId, final long errorCode,
|
public ChannelFuture goAway(final ChannelHandlerContext ctx, final int lastStreamId, final long errorCode,
|
||||||
final ByteBuf debugData, ChannelPromise promise) {
|
final ByteBuf debugData, ChannelPromise promise) {
|
||||||
boolean release = false;
|
|
||||||
try {
|
try {
|
||||||
promise = promise.unvoid();
|
promise = promise.unvoid();
|
||||||
final Http2Connection connection = connection();
|
final Http2Connection connection = connection();
|
||||||
@ -692,7 +691,6 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
|||||||
// Need to retain before we write the buffer because if we do it after the refCnt could already be 0 and
|
// Need to retain before we write the buffer because if we do it after the refCnt could already be 0 and
|
||||||
// result in an IllegalRefCountException.
|
// result in an IllegalRefCountException.
|
||||||
debugData.retain();
|
debugData.retain();
|
||||||
release = true;
|
|
||||||
ChannelFuture future = frameWriter().writeGoAway(ctx, lastStreamId, errorCode, debugData, promise);
|
ChannelFuture future = frameWriter().writeGoAway(ctx, lastStreamId, errorCode, debugData, promise);
|
||||||
|
|
||||||
if (future.isDone()) {
|
if (future.isDone()) {
|
||||||
@ -708,9 +706,7 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
|||||||
|
|
||||||
return future;
|
return future;
|
||||||
} catch (Throwable cause) { // Make sure to catch Throwable because we are doing a retain() in this method.
|
} catch (Throwable cause) { // Make sure to catch Throwable because we are doing a retain() in this method.
|
||||||
if (release) {
|
|
||||||
debugData.release();
|
debugData.release();
|
||||||
}
|
|
||||||
return promise.setFailure(cause);
|
return promise.setFailure(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import static io.netty.handler.codec.http2.Http2TestUtil.newVoidPromise;
|
|||||||
import static io.netty.util.CharsetUtil.UTF_8;
|
import static io.netty.util.CharsetUtil.UTF_8;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyBoolean;
|
import static org.mockito.Matchers.anyBoolean;
|
||||||
@ -425,7 +426,6 @@ public class Http2ConnectionHandlerTest {
|
|||||||
public void cannotSendGoAwayFrameWithIncreasingLastStreamIds() throws Exception {
|
public void cannotSendGoAwayFrameWithIncreasingLastStreamIds() throws Exception {
|
||||||
handler = newHandler();
|
handler = newHandler();
|
||||||
ByteBuf data = dummyData();
|
ByteBuf data = dummyData();
|
||||||
try {
|
|
||||||
long errorCode = Http2Error.INTERNAL_ERROR.code();
|
long errorCode = Http2Error.INTERNAL_ERROR.code();
|
||||||
|
|
||||||
handler.goAway(ctx, STREAM_ID, errorCode, data.retain(), promise);
|
handler.goAway(ctx, STREAM_ID, errorCode, data.retain(), promise);
|
||||||
@ -439,11 +439,8 @@ public class Http2ConnectionHandlerTest {
|
|||||||
handler.goAway(ctx, STREAM_ID + 2, errorCode, data, promise);
|
handler.goAway(ctx, STREAM_ID + 2, errorCode, data, promise);
|
||||||
assertTrue(promise.isDone());
|
assertTrue(promise.isDone());
|
||||||
assertFalse(promise.isSuccess());
|
assertFalse(promise.isSuccess());
|
||||||
assertEquals(1, data.refCnt());
|
assertEquals(0, data.refCnt());
|
||||||
verifyNoMoreInteractions(frameWriter);
|
verifyNoMoreInteractions(frameWriter);
|
||||||
} finally {
|
|
||||||
data.release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user