Skip to content

Commit 1507763

Browse files
committed
remove requestSessionOutput() calls
1 parent 1d28749 commit 1507763

2 files changed

Lines changed: 0 additions & 80 deletions

File tree

httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,6 @@ private void consumeFrame(final RawFrame frame) throws HttpException, IOExceptio
835835
stream.activate();
836836
streams.resetIfExceedsMaxConcurrentLimit(stream, localConfig.getMaxConcurrentStreams());
837837
}
838-
if (resetIfExpired(stream, nowNanos)) {
839-
requestSessionOutput();
840-
break;
841-
}
842838
try {
843839
consumeHeaderFrame(frame, stream);
844840
if (stream.isOutputReady()) {

httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestAbstractH2StreamMultiplexer.java

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,82 +1294,6 @@ void testExpiredStreamResetOnInboundData() throws Exception {
12941294
ArgumentMatchers.any(ByteBuffer.class), ArgumentMatchers.anyBoolean());
12951295
}
12961296

1297-
@Test
1298-
void testExpiredStreamResetOnInboundHeaders() throws Exception {
1299-
Mockito.when(protocolIOSession.write(ArgumentMatchers.any(ByteBuffer.class)))
1300-
.thenAnswer(invocation -> {
1301-
final ByteBuffer buffer = invocation.getArgument(0, ByteBuffer.class);
1302-
final int remaining = buffer.remaining();
1303-
buffer.position(buffer.limit());
1304-
return remaining;
1305-
});
1306-
Mockito.doNothing().when(protocolIOSession).setEvent(ArgumentMatchers.anyInt());
1307-
Mockito.doNothing().when(protocolIOSession).clearEvent(ArgumentMatchers.anyInt());
1308-
1309-
final H2Config h2Config = H2Config.custom().build();
1310-
final AbstractH2StreamMultiplexer mux = new H2StreamMultiplexerImpl(
1311-
protocolIOSession,
1312-
FRAME_FACTORY,
1313-
StreamIdGenerator.EVEN,
1314-
httpProcessor,
1315-
CharCodingConfig.DEFAULT,
1316-
h2Config,
1317-
h2StreamListener,
1318-
() -> streamHandler);
1319-
1320-
// Encode request headers
1321-
final ByteArrayBuffer headerBuf = new ByteArrayBuffer(200);
1322-
final HPackEncoder encoder = new HPackEncoder(h2Config.getHeaderTableSize(),
1323-
CharCodingSupport.createEncoder(CharCodingConfig.DEFAULT));
1324-
final List<Header> headers = Arrays.asList(
1325-
new BasicHeader(":method", "POST"),
1326-
new BasicHeader(":scheme", "http"),
1327-
new BasicHeader(":path", "/"),
1328-
new BasicHeader(":authority", "www.example.com"));
1329-
encoder.encodeHeaders(headerBuf, headers, h2Config.isCompressionEnabled());
1330-
1331-
final WritableByteChannelMock writableChannel = new WritableByteChannelMock(1024);
1332-
final FrameOutputBuffer outBuffer = new FrameOutputBuffer(16 * 1024);
1333-
1334-
// Send initial HEADERS (endHeaders=true, endStream=false) to create stream 1
1335-
final RawFrame headerFrame = FRAME_FACTORY.createHeaders(1,
1336-
ByteBuffer.wrap(headerBuf.array(), 0, headerBuf.length()), true, false);
1337-
outBuffer.write(headerFrame, writableChannel);
1338-
mux.onInput(ByteBuffer.wrap(writableChannel.toByteArray()));
1339-
1340-
Mockito.verify(streamHandler).consumeHeader(headersCaptor.capture(), ArgumentMatchers.eq(false));
1341-
Assertions.assertFalse(headersCaptor.getValue().isEmpty());
1342-
1343-
// Retrieve the stream and set a short timeout
1344-
final Field streamsField = AbstractH2StreamMultiplexer.class.getDeclaredField("streams");
1345-
streamsField.setAccessible(true);
1346-
final H2Streams h2Streams = (H2Streams) streamsField.get(mux);
1347-
final H2Stream stream = h2Streams.lookupValid(1);
1348-
stream.setTimeout(Timeout.ofMilliseconds(50));
1349-
1350-
// Push last activity into the past so the timeout is expired
1351-
final Field lastActivityField = H2Stream.class.getDeclaredField("lastActivityNanos");
1352-
lastActivityField.setAccessible(true);
1353-
lastActivityField.set(stream, System.nanoTime() - TimeUnit.MILLISECONDS.toNanos(100));
1354-
1355-
// Send trailing HEADERS (endHeaders=true, endStream=true) for the expired stream
1356-
writableChannel.reset();
1357-
final ByteArrayBuffer trailerBuf = new ByteArrayBuffer(64);
1358-
encoder.encodeHeaders(trailerBuf, Arrays.asList(
1359-
new BasicHeader("x-checksum", "abc123")), h2Config.isCompressionEnabled());
1360-
final RawFrame trailerFrame = FRAME_FACTORY.createHeaders(1,
1361-
ByteBuffer.wrap(trailerBuf.array(), 0, trailerBuf.length()), true, true);
1362-
outBuffer.write(trailerFrame, writableChannel);
1363-
mux.onInput(ByteBuffer.wrap(writableChannel.toByteArray()));
1364-
1365-
// The handler must receive a timeout failure, not a second header consumption
1366-
Mockito.verify(streamHandler).failed(exceptionCaptor.capture());
1367-
Assertions.assertInstanceOf(H2StreamTimeoutException.class, exceptionCaptor.getValue());
1368-
// consumeHeader was called exactly once (the initial HEADERS), not twice
1369-
Mockito.verify(streamHandler, Mockito.times(1)).consumeHeader(
1370-
ArgumentMatchers.anyList(), ArgumentMatchers.anyBoolean());
1371-
}
1372-
13731297
@Test
13741298
void testExpiredStreamResetOnInboundContinuation() throws Exception {
13751299
Mockito.when(protocolIOSession.write(ArgumentMatchers.any(ByteBuffer.class)))

0 commit comments

Comments
 (0)