File tree Expand file tree Collapse file tree 2 files changed +56
-3
lines changed
main/java/io/vertx/core/net/impl/quic
test/java/io/vertx/tests/net/quic Expand file tree Collapse file tree 2 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -106,9 +106,16 @@ protected long sizeof(Object msg) {
106106 @ Override
107107 public Future <Void > end () {
108108 PromiseInternal <Void > promise = context .promise ();
109- writeToChannel (() -> {
110- ChannelFuture shutdownPromise = channel .shutdownOutput ();
111- shutdownPromise .addListener (promise );
109+ writeToChannel (new MessageWrite () {
110+ @ Override
111+ public void write () {
112+ ChannelFuture shutdownPromise = channel .shutdownOutput ();
113+ shutdownPromise .addListener (promise );
114+ }
115+ @ Override
116+ public void cancel (Throwable cause ) {
117+ promise .fail (cause );
118+ }
112119 });
113120 return promise .future ();
114121 }
Original file line number Diff line number Diff line change @@ -813,6 +813,52 @@ private List<String> testKeyLogFile(File keyLogFile) throws Exception {
813813 }
814814 }
815815
816+ @ Test
817+ public void testWriteWhenClosed () throws Exception {
818+ testWriteWhenClosed (true );
819+ }
820+
821+ @ Test
822+ public void testEndWhenClosed () throws Exception {
823+ testWriteWhenClosed (false );
824+ }
825+
826+ private void testWriteWhenClosed (boolean write ) throws Exception {
827+ disableThreadChecks ();
828+ QuicServer server = QuicServer .create (vertx , serverOptions ());
829+ server .handler (conn -> {
830+ conn .streamHandler (stream -> {
831+ stream .closeHandler (v -> {
832+ Future <Void > f ;
833+ if (write ) {
834+ f = stream .write ("test" );
835+ } else {
836+ f = stream .end ();
837+ }
838+ f .onComplete (onFailure2 (err -> {
839+ testComplete ();
840+ }));
841+ });
842+ stream .handler (buff -> {
843+ stream .close ();
844+ });
845+ });
846+ });
847+ server .bind (SocketAddress .inetSocketAddress (9999 , "localhost" )).await ();
848+ QuicTestClient client = new QuicTestClient (new NioEventLoopGroup (1 ));
849+ try {
850+ client = new QuicTestClient (new NioEventLoopGroup (1 ));
851+ QuicTestClient .Connection connection = client .connect (new InetSocketAddress (NetUtil .LOCALHOST4 , 9999 ));
852+ QuicTestClient .Stream stream = connection .newStream ();
853+ stream .create ();
854+ stream .write ("ping" );
855+ await ();
856+ } finally {
857+ client .close ();
858+ server .close ().await ();
859+ }
860+ }
861+
816862 /* @Test
817863 public void testSoReuse() throws Exception {
818864
You can’t perform that action at this time.
0 commit comments