@@ -201,7 +201,13 @@ public void tearDown() {
201201
202202 @ Test
203203 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+ });
205211 InOrder inOrder = inOrder (helper );
206212 inOrder .verify (helper )
207213 .updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -236,7 +242,13 @@ public void lb_serverStatusCodeConversion() throws Exception {
236242
237243 @ Test
238244 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+ });
240252 InOrder inOrder = inOrder (helper );
241253 inOrder .verify (helper )
242254 .updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -257,7 +269,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
257269 inOrder .verifyNoMoreInteractions ();
258270
259271 assertThat (res .getStatus ().isOk ()).isTrue ();
260- assertThat (subchannels ).hasSize (1 );
272+ assertThat (subchannels ).hasSize (2 ); // includes fallback sub-channel
261273 FakeSubchannel searchSubchannel = subchannels .getLast ();
262274 assertThat (subchannelIsReady (searchSubchannel )).isFalse ();
263275
@@ -277,7 +289,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
277289 // other rls picker itself is ready due to first channel.
278290 assertThat (res .getStatus ().isOk ()).isTrue ();
279291 assertThat (subchannelIsReady (res .getSubchannel ())).isFalse ();
280- assertThat (subchannels ).hasSize (2 );
292+ assertThat (subchannels ).hasSize (3 ); // includes fallback sub-channel
281293 FakeSubchannel rescueSubchannel = subchannels .getLast ();
282294
283295 // search subchannel is down, rescue subchannel is connecting
@@ -393,7 +405,13 @@ public void lb_working_withoutDefaultTarget_noRlsResponse() throws Exception {
393405 public void lb_working_withDefaultTarget_noRlsResponse () throws Exception {
394406 fakeThrottler .nextResult = true ;
395407
396- deliverResolvedAddresses ();
408+ helper .getSynchronizationContext ().execute (() -> {
409+ try {
410+ deliverResolvedAddresses ();
411+ } catch (Exception e ) {
412+ throw new RuntimeException (e );
413+ }
414+ });
397415 InOrder inOrder = inOrder (helper );
398416 inOrder .verify (helper )
399417 .updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -535,7 +553,13 @@ public void lb_working_withoutDefaultTarget() throws Exception {
535553
536554 @ Test
537555 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+ });
539563 InOrder inOrder = inOrder (helper );
540564 inOrder .verify (helper )
541565 .updateBalancingState (eq (ConnectivityState .CONNECTING ), pickerCaptor .capture ());
@@ -545,7 +569,7 @@ public void lb_nameResolutionFailed() throws Exception {
545569 assertThat (subchannelIsReady (res .getSubchannel ())).isFalse ();
546570
547571 inOrder .verify (helper ).createSubchannel (any (CreateSubchannelArgs .class ));
548- assertThat (subchannels ).hasSize (1 );
572+ assertThat (subchannels ).hasSize (2 ); // includes fallback sub-channel
549573
550574 FakeSubchannel searchSubchannel = subchannels .getLast ();
551575 searchSubchannel .updateState (ConnectivityStateInfo .forNonError (ConnectivityState .READY ));
0 commit comments