|
64 | 64 | import org.apache.hc.core5.http.nio.AsyncPushConsumer; |
65 | 65 | import org.apache.hc.core5.http.nio.AsyncPushProducer; |
66 | 66 | import org.apache.hc.core5.http.nio.HandlerFactory; |
| 67 | +import org.apache.hc.core5.http.nio.command.CommandSupport; |
67 | 68 | import org.apache.hc.core5.http.nio.command.ExecutableCommand; |
68 | 69 | import org.apache.hc.core5.http.nio.command.ShutdownCommand; |
69 | 70 | import org.apache.hc.core5.http.protocol.HttpCoreContext; |
@@ -576,18 +577,7 @@ public final void onDisconnect() { |
576 | 577 | final H2Stream stream = entry.getValue(); |
577 | 578 | stream.cancel(); |
578 | 579 | } |
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); |
591 | 581 | } |
592 | 582 |
|
593 | 583 | private void processPendingCommands() throws IOException, HttpException { |
@@ -662,18 +652,7 @@ public final void onException(final Exception cause) { |
662 | 652 | break; |
663 | 653 | } |
664 | 654 | } |
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); |
677 | 656 | for (final Iterator<Map.Entry<Integer, H2Stream>> it = streamMap.entrySet().iterator(); it.hasNext(); ) { |
678 | 657 | final Map.Entry<Integer, H2Stream> entry = it.next(); |
679 | 658 | final H2Stream stream = entry.getValue(); |
|
0 commit comments