Skip to content

Commit faf44e8

Browse files
committed
Use RequestNotExecutedException instead of ConnectionClosedException when failing enqueued requests that never got executed
1 parent 5b1a796 commit faf44e8

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
6565
import org.apache.hc.core5.http.nio.AsyncPushProducer;
6666
import org.apache.hc.core5.http.nio.HandlerFactory;
67+
import org.apache.hc.core5.http.nio.command.CommandSupport;
6768
import org.apache.hc.core5.http.nio.command.ExecutableCommand;
6869
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
6970
import org.apache.hc.core5.http.protocol.HttpCoreContext;
@@ -576,18 +577,7 @@ public final void onDisconnect() {
576577
final H2Stream stream = entry.getValue();
577578
stream.cancel();
578579
}
579-
for (;;) {
580-
final Command command = ioSession.poll();
581-
if (command != null) {
582-
if (command instanceof ExecutableCommand) {
583-
((ExecutableCommand) command).failed(new ConnectionClosedException());
584-
} else {
585-
command.cancel();
586-
}
587-
} else {
588-
break;
589-
}
590-
}
580+
CommandSupport.cancelCommands(ioSession);
591581
}
592582

593583
private void processPendingCommands() throws IOException, HttpException {
@@ -662,18 +652,7 @@ public final void onException(final Exception cause) {
662652
break;
663653
}
664654
}
665-
for (;;) {
666-
final Command command = ioSession.poll();
667-
if (command != null) {
668-
if (command instanceof ExecutableCommand) {
669-
((ExecutableCommand) command).failed(new ConnectionClosedException());
670-
} else {
671-
command.cancel();
672-
}
673-
} else {
674-
break;
675-
}
676-
}
655+
CommandSupport.cancelCommands(ioSession);
677656
for (final Iterator<Map.Entry<Integer, H2Stream>> it = streamMap.entrySet().iterator(); it.hasNext(); ) {
678657
final Map.Entry<Integer, H2Stream> entry = it.next();
679658
final H2Stream stream = entry.getValue();

0 commit comments

Comments
 (0)