@@ -183,7 +183,7 @@ void publisherWritesFutureCompletesAfterConnectionClosed_shouldNotInvokeIncremen
183
183
}
184
184
185
185
@ Test
186
- void publisherWritesFutureCompletesWhenConnectionClosed_shouldNotInvokeIncrementWindow () {
186
+ void publisherWritesFutureCompletesBeforeConnectionClosed_shouldInvokeIncrementWindow () {
187
187
CompletableFuture <Void > future = new CompletableFuture <>();
188
188
when (simplePublisher .send (any (ByteBuffer .class ))).thenReturn (future );
189
189
when (simplePublisher .complete ()).thenReturn (future );
@@ -199,23 +199,10 @@ void publisherWritesFutureCompletesWhenConnectionClosed_shouldNotInvokeIncrement
199
199
handler .onResponseBody (httpStream ,
200
200
RandomStringUtils .random (1 * 1024 * 1024 ).getBytes (StandardCharsets .UTF_8 ));
201
201
202
- // This tracker tracks which of the two operation completes first
203
- AtomicInteger whenCompleteTracker = new AtomicInteger (0 );
204
- CompletableFuture <Void > onResponseComplete = CompletableFuture .runAsync (() -> handler .onResponseComplete (httpStream , 0 ))
205
- .whenComplete ((r , t ) -> whenCompleteTracker .compareAndSet (0 , 1 ));
206
-
207
- CompletableFuture <Void > writeComplete = CompletableFuture .runAsync (() -> future .complete (null ))
208
- .whenComplete ((r , t ) -> whenCompleteTracker .compareAndSet (0 , 2 ));
202
+ future .complete (null );
203
+ handler .onResponseComplete (httpStream , 0 );
209
204
requestFuture .join ();
210
-
211
- CompletableFuture .allOf (onResponseComplete , writeComplete ).join ();
212
-
213
- if (whenCompleteTracker .get () == 1 ) {
214
- // onResponseComplete finishes first
215
- verify (httpStream , never ()).incrementWindow (anyInt ());
216
- } else {
217
- verify (httpStream ).incrementWindow (anyInt ());
218
- }
205
+ verify (httpStream ).incrementWindow (anyInt ());
219
206
220
207
verify (crtConn , never ()).shutdown ();
221
208
verify (crtConn ).close ();
0 commit comments