@@ -2440,6 +2440,7 @@ public void testSynchronousExecutionTimeoutValueViaExecute() {
2440
2440
2441
2441
System .out .println (">>>>> Begin: " + System .currentTimeMillis ());
2442
2442
2443
+ final AtomicBoolean startedExecution = new AtomicBoolean ();
2443
2444
HystrixObservableCommand <String > command = new HystrixObservableCommand <String >(properties ) {
2444
2445
@ Override
2445
2446
protected Observable <String > construct () {
@@ -2449,6 +2450,7 @@ protected Observable<String> construct() {
2449
2450
@ Override
2450
2451
public void call (Subscriber <? super String > t1 ) {
2451
2452
try {
2453
+ startedExecution .set (true );
2452
2454
Thread .sleep (2000 );
2453
2455
} catch (InterruptedException e ) {
2454
2456
e .printStackTrace ();
@@ -2477,7 +2479,7 @@ protected Observable<String> resumeWithFallback() {
2477
2479
assertEquals ("expected fallback value" , "timed-out" , value );
2478
2480
2479
2481
// Thread isolated
2480
- assertTrue (command .isExecutedInThread ());
2482
+ assertTrue (! startedExecution . get () || command .isExecutedInThread ());
2481
2483
assertNotNull (command .getExecutionException ());
2482
2484
2483
2485
assertEquals (0 , command .metrics .getCurrentConcurrentExecutionCount ());
@@ -2493,13 +2495,15 @@ public void testSynchronousExecutionUsingThreadIsolationTimeoutValueViaObserve()
2493
2495
.withExecutionIsolationStrategy (ExecutionIsolationStrategy .THREAD )
2494
2496
.withExecutionTimeoutInMilliseconds (50 ));
2495
2497
2498
+ final AtomicBoolean startedExecution = new AtomicBoolean ();
2496
2499
HystrixObservableCommand <String > command = new HystrixObservableCommand <String >(properties ) {
2497
2500
@ Override
2498
2501
protected Observable <String > construct () {
2499
2502
return Observable .create (new OnSubscribe <String >() {
2500
2503
2501
2504
@ Override
2502
2505
public void call (Subscriber <? super String > t1 ) {
2506
+ startedExecution .set (true );
2503
2507
try {
2504
2508
Thread .sleep (2000 );
2505
2509
} catch (InterruptedException e ) {
@@ -2527,7 +2531,7 @@ protected Observable<String> resumeWithFallback() {
2527
2531
assertEquals ("expected fallback value" , "timed-out" , value );
2528
2532
2529
2533
// Thread isolated
2530
- assertTrue (command .isExecutedInThread ());
2534
+ assertTrue (! startedExecution . get () || command .isExecutedInThread ());
2531
2535
assertNotNull (command .getExecutionException ());
2532
2536
2533
2537
assertEquals (0 , command .metrics .getCurrentConcurrentExecutionCount ());
0 commit comments