From 93dfbcb6178ce01aa438aae36599e5214e8bc89f Mon Sep 17 00:00:00 2001 From: Christoph Seibert Date: Wed, 25 Apr 2018 17:41:47 +0200 Subject: [PATCH 1/2] Only check for thread isolation if the command had a chance to start executing --- .../com/netflix/hystrix/HystrixObservableCommandTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java index 58964f6ee..4550d3605 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java @@ -2493,6 +2493,7 @@ public void testSynchronousExecutionUsingThreadIsolationTimeoutValueViaObserve() .withExecutionIsolationStrategy(ExecutionIsolationStrategy.THREAD) .withExecutionTimeoutInMilliseconds(50)); + final AtomicBoolean startedExecution = new AtomicBoolean(); HystrixObservableCommand command = new HystrixObservableCommand(properties) { @Override protected Observable construct() { @@ -2500,6 +2501,7 @@ protected Observable construct() { @Override public void call(Subscriber t1) { + startedExecution.set(true); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -2527,7 +2529,7 @@ protected Observable resumeWithFallback() { assertEquals("expected fallback value", "timed-out", value); // Thread isolated - assertTrue(command.isExecutedInThread()); + assertTrue(!startedExecution.get() || command.isExecutedInThread()); assertNotNull(command.getExecutionException()); assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount()); From 86eb9458990d1d0f677ac4de920b4289d722e105 Mon Sep 17 00:00:00 2001 From: Christoph Seibert Date: Fri, 27 Apr 2018 09:30:29 +0200 Subject: [PATCH 2/2] Again: Only check for thread isolation if the command had a chance to start executing --- .../com/netflix/hystrix/HystrixObservableCommandTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java index 4550d3605..f455f6bad 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java @@ -2440,6 +2440,7 @@ public void testSynchronousExecutionTimeoutValueViaExecute() { System.out.println(">>>>> Begin: " + System.currentTimeMillis()); + final AtomicBoolean startedExecution = new AtomicBoolean(); HystrixObservableCommand command = new HystrixObservableCommand(properties) { @Override protected Observable construct() { @@ -2449,6 +2450,7 @@ protected Observable construct() { @Override public void call(Subscriber t1) { try { + startedExecution.set(true); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); @@ -2477,7 +2479,7 @@ protected Observable resumeWithFallback() { assertEquals("expected fallback value", "timed-out", value); // Thread isolated - assertTrue(command.isExecutedInThread()); + assertTrue(!startedExecution.get() || command.isExecutedInThread()); assertNotNull(command.getExecutionException()); assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount());