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

IllegalStateException: Future Not Started #81

Merged
merged 1 commit into from
Jan 8, 2013
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@ private class QueuedExecutionFuture implements CommandFuture<R> {
private volatile R result; // the result of the get()
private volatile ExecutionException executionException; // in case an exception is thrown
private volatile Future<R> actualFuture = null;
private volatile boolean isInterrupted = false;
private final CountDownLatch futureStarted = new CountDownLatch(1);
private final AtomicBoolean started = new AtomicBoolean(false);

Expand Down Expand Up @@ -1381,6 +1382,7 @@ private void start() {
// wait for if block above to finish on a different thread
futureStarted.await();
} catch (InterruptedException e) {
isInterrupted = true;
logger.error(getLogMessagePrefix() + ": Unexpected interruption while waiting on other thread submitting to queue.", e);
actualFuture = asFuture(getFallbackOrThrowException(HystrixEventType.THREAD_POOL_REJECTED, FailureType.REJECTED_THREAD_EXECUTION, "Unexpected interruption while waiting on other thread submitting to queue.", e));
}
Expand Down Expand Up @@ -1450,7 +1452,20 @@ private void performActualGet() throws CancellationException, InterruptedExcepti
// this check needs to be inside the try/finally so even if an exception is thrown
// we will countDown the latch and release threads
if (!started.get() || actualFuture == null) {
throw new IllegalStateException("Future was not started.");
/**
* https://github.com/Netflix/Hystrix/issues/80
*
* Output any extra information that can help tracking down how this failed
* as it most likely means there's a concurrency bug.
*/
throw new IllegalStateException("Future was not started. Key: "
+ getCommandKey().name() + " ActualFuture: " + actualFuture
+ " Started: " + started.get() + " actualFutureExecuted: " + actualFutureExecuted.get()
+ " futureStarted: " + futureStarted.getCount()
+ " isInterrupted: " + isInterrupted
+ " actualResponseReceived: " + actualResponseReceived.getCount()
+ " isCommandTimedOut: " + isCommandTimedOut.get()
+ " Events: " + Arrays.toString(getExecutionEvents().toArray()));
}
// get on the actualFuture with timeout values from properties
result = actualFuture.get(properties.executionIsolationThreadTimeoutInMilliseconds().get(), TimeUnit.MILLISECONDS);
Expand Down