@@ -2783,6 +2783,32 @@ public void negotiateSentOnStart() {
2783
2783
assertEquals ("http://example.com/negotiate?negotiateVersion=1" , sentRequests .get (0 ).getUrl ());
2784
2784
}
2785
2785
2786
+ @ Test
2787
+ public void closeWithPendingNegotiate () {
2788
+ SingleSubject <HttpResponse > responseSubject = SingleSubject .create ();
2789
+
2790
+ TestHttpClient client = new TestHttpClient ()
2791
+ .on ("POST" , (req ) -> responseSubject );
2792
+
2793
+ HubConnection hubConnection = HubConnectionBuilder
2794
+ .create ("http://example.com" )
2795
+ .withHttpClient (client )
2796
+ .build ();
2797
+
2798
+ Completable start = hubConnection .start ();
2799
+ assertEquals (HubConnectionState .CONNECTING , hubConnection .getConnectionState ());
2800
+
2801
+ Completable stop = hubConnection .stop ();
2802
+
2803
+ responseSubject .onSuccess (new HttpResponse (404 , "" , TestUtils .emptyByteBuffer ));
2804
+ stop .timeout (3 , TimeUnit .SECONDS ).blockingAwait ();
2805
+ assertEquals (HubConnectionState .DISCONNECTED , hubConnection .getConnectionState ());
2806
+
2807
+ HttpRequestException exception = assertThrows (HttpRequestException .class , () -> start .blockingAwait (10 , TimeUnit .SECONDS ));
2808
+ assertEquals ("Unexpected status code returned from negotiate: 404 ." , exception .getMessage ());
2809
+ assertEquals (404 , exception .getStatusCode ());
2810
+ }
2811
+
2786
2812
@ Test
2787
2813
public void negotiateThatRedirectsForeverFailsAfter100Tries () {
2788
2814
TestHttpClient client = new TestHttpClient ().on ("POST" , "http://example.com/negotiate?negotiateVersion=1" ,
0 commit comments