Skip to content

Commit 0de44bf

Browse files
IllegalStateException: Future Not Started
Netflix#80 Adding much more detail exception message to help in debugging this when it happens as it shouldn't ever happen.
1 parent ea9b56e commit 0de44bf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ private class QueuedExecutionFuture implements CommandFuture<R> {
13341334
private volatile R result; // the result of the get()
13351335
private volatile ExecutionException executionException; // in case an exception is thrown
13361336
private volatile Future<R> actualFuture = null;
1337+
private volatile boolean isInterrupted = false;
13371338
private final CountDownLatch futureStarted = new CountDownLatch(1);
13381339
private final AtomicBoolean started = new AtomicBoolean(false);
13391340

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

0 commit comments

Comments
 (0)