Created
April 30, 2013 22:31
-
-
Save dcapwell/5492453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public C get(final long timeout, final TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException { | |
try { | |
return super.get(timeout, unit); | |
} catch (TimeoutException e) { | |
Function<List<Optional<V>>, C> localCombiner = combiner; | |
if (localCombiner != null) { | |
// if the set took or not we don't care, if it doesn't take it means that it was set by the last future. | |
set(localCombiner.apply(values)); | |
} else { | |
// if combiner is null, then we should be done and have data. | |
checkState(isDone()); | |
} | |
// ether the state is messed up and an exception is thrown, or set was called which means data is present | |
// this shouldn't block. | |
return super.get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment