Skip to content

Commit 7f5a0af

Browse files
author
Tim Bozarth
authored
Merge pull request #1797 from MenschNestor/master
Stabilize yet another test
2 parents 7184bdc + 86eb945 commit 7f5a0af

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,7 @@ public void testSynchronousExecutionTimeoutValueViaExecute() {
24402440

24412441
System.out.println(">>>>> Begin: " + System.currentTimeMillis());
24422442

2443+
final AtomicBoolean startedExecution = new AtomicBoolean();
24432444
HystrixObservableCommand<String> command = new HystrixObservableCommand<String>(properties) {
24442445
@Override
24452446
protected Observable<String> construct() {
@@ -2449,6 +2450,7 @@ protected Observable<String> construct() {
24492450
@Override
24502451
public void call(Subscriber<? super String> t1) {
24512452
try {
2453+
startedExecution.set(true);
24522454
Thread.sleep(2000);
24532455
} catch (InterruptedException e) {
24542456
e.printStackTrace();
@@ -2477,7 +2479,7 @@ protected Observable<String> resumeWithFallback() {
24772479
assertEquals("expected fallback value", "timed-out", value);
24782480

24792481
// Thread isolated
2480-
assertTrue(command.isExecutedInThread());
2482+
assertTrue(!startedExecution.get() || command.isExecutedInThread());
24812483
assertNotNull(command.getExecutionException());
24822484

24832485
assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount());
@@ -2493,13 +2495,15 @@ public void testSynchronousExecutionUsingThreadIsolationTimeoutValueViaObserve()
24932495
.withExecutionIsolationStrategy(ExecutionIsolationStrategy.THREAD)
24942496
.withExecutionTimeoutInMilliseconds(50));
24952497

2498+
final AtomicBoolean startedExecution = new AtomicBoolean();
24962499
HystrixObservableCommand<String> command = new HystrixObservableCommand<String>(properties) {
24972500
@Override
24982501
protected Observable<String> construct() {
24992502
return Observable.create(new OnSubscribe<String>() {
25002503

25012504
@Override
25022505
public void call(Subscriber<? super String> t1) {
2506+
startedExecution.set(true);
25032507
try {
25042508
Thread.sleep(2000);
25052509
} catch (InterruptedException e) {
@@ -2527,7 +2531,7 @@ protected Observable<String> resumeWithFallback() {
25272531
assertEquals("expected fallback value", "timed-out", value);
25282532

25292533
// Thread isolated
2530-
assertTrue(command.isExecutedInThread());
2534+
assertTrue(!startedExecution.get() || command.isExecutedInThread());
25312535
assertNotNull(command.getExecutionException());
25322536

25332537
assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount());

0 commit comments

Comments
 (0)