Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test demonstrating that a timeout does not fire properly when command.queue() is called with no blocking performed on the resulting Future #515

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,29 @@ public void testShortCircuitFallbackCounter() {
assertEquals(2, HystrixRequestLog.getCurrentRequest().getExecutedCommands().size());
}

@Test
public void testNonBlockingCommandQueueFiresTimeout() { //see https://github.com/Netflix/Hystrix/issues/514
final TestHystrixCommand<Boolean> cmd = new TestCommandWithTimeout(50, TestCommandWithTimeout.FALLBACK_SUCCESS);

new Thread() {
@Override
public void run() {
cmd.queue();
}
}.start();

try {
Thread.sleep(200);
//timeout should occur in 50ms, and underlying thread should run for 500ms
//therefore, after 200ms, the command should have finished with a fallback on timeout
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
}

assertTrue(cmd.isExecutionComplete());
assertTrue(cmd.isResponseTimedOut());
}

/**
* Test when a command fails to get queued up in the threadpool where the command didn't implement getFallback.
* <p>
Expand Down