@@ -201,7 +201,13 @@ public void tearDown() {
201
201
202
202
@ Test
203
203
public void lb_serverStatusCodeConversion () throws Exception {
204
- deliverResolvedAddresses ();
204
+ helper .getSynchronizationContext ().execute (() -> {
205
+ try {
206
+ deliverResolvedAddresses ();
207
+ } catch (Exception e ) {
208
+ throw new RuntimeException (e );
209
+ }
210
+ });
205
211
InOrder inOrder = inOrder (helper );
206
212
inOrder .verify (helper )
207
213
.updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -236,7 +242,13 @@ public void lb_serverStatusCodeConversion() throws Exception {
236
242
237
243
@ Test
238
244
public void lb_working_withDefaultTarget_rlsResponding () throws Exception {
239
- deliverResolvedAddresses ();
245
+ helper .getSynchronizationContext ().execute (() -> {
246
+ try {
247
+ deliverResolvedAddresses ();
248
+ } catch (Exception e ) {
249
+ throw new RuntimeException (e );
250
+ }
251
+ });
240
252
InOrder inOrder = inOrder (helper );
241
253
inOrder .verify (helper )
242
254
.updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -257,7 +269,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
257
269
inOrder .verifyNoMoreInteractions ();
258
270
259
271
assertThat (res .getStatus ().isOk ()).isTrue ();
260
- assertThat (subchannels ).hasSize (1 );
272
+ assertThat (subchannels ).hasSize (2 ); // includes fallback sub-channel
261
273
FakeSubchannel searchSubchannel = subchannels .getLast ();
262
274
assertThat (subchannelIsReady (searchSubchannel )).isFalse ();
263
275
@@ -277,7 +289,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
277
289
// other rls picker itself is ready due to first channel.
278
290
assertThat (res .getStatus ().isOk ()).isTrue ();
279
291
assertThat (subchannelIsReady (res .getSubchannel ())).isFalse ();
280
- assertThat (subchannels ).hasSize (2 );
292
+ assertThat (subchannels ).hasSize (3 ); // includes fallback sub-channel
281
293
FakeSubchannel rescueSubchannel = subchannels .getLast ();
282
294
283
295
// search subchannel is down, rescue subchannel is connecting
@@ -393,7 +405,13 @@ public void lb_working_withoutDefaultTarget_noRlsResponse() throws Exception {
393
405
public void lb_working_withDefaultTarget_noRlsResponse () throws Exception {
394
406
fakeThrottler .nextResult = true ;
395
407
396
- deliverResolvedAddresses ();
408
+ helper .getSynchronizationContext ().execute (() -> {
409
+ try {
410
+ deliverResolvedAddresses ();
411
+ } catch (Exception e ) {
412
+ throw new RuntimeException (e );
413
+ }
414
+ });
397
415
InOrder inOrder = inOrder (helper );
398
416
inOrder .verify (helper )
399
417
.updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -535,7 +553,13 @@ public void lb_working_withoutDefaultTarget() throws Exception {
535
553
536
554
@ Test
537
555
public void lb_nameResolutionFailed () throws Exception {
538
- deliverResolvedAddresses ();
556
+ helper .getSynchronizationContext ().execute (() -> {
557
+ try {
558
+ deliverResolvedAddresses ();
559
+ } catch (Exception e ) {
560
+ throw new RuntimeException (e );
561
+ }
562
+ });
539
563
InOrder inOrder = inOrder (helper );
540
564
inOrder .verify (helper )
541
565
.updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -545,7 +569,7 @@ public void lb_nameResolutionFailed() throws Exception {
545
569
assertThat (subchannelIsReady (res .getSubchannel ())).isFalse ();
546
570
547
571
inOrder .verify (helper ).createSubchannel (any (CreateSubchannelArgs .class ));
548
- assertThat (subchannels ).hasSize (1 );
572
+ assertThat (subchannels ).hasSize (2 ); // includes fallback sub-channel
549
573
550
574
FakeSubchannel searchSubchannel = subchannels .getLast ();
551
575
searchSubchannel .updateState (ConnectivityStateInfo .forNonError (ConnectivityState .READY ));
0 commit comments