Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
qpid-java-6.0
-
None
Description
We have a number of cases in asynchronous model operations where we chain code to run after a future completes, returning a future to the caller that completes once the chained code completes.
The idiom looks like this:
public ListenableFuture<Void> doMyStateChangeOp() { final SettableFuture<Void> returnVal = SettableFuture.create(); ListenableFuture opFuture = operationAsync(); opFuture.addListener(new Runnable() { // some code returnVal.set(null); }); return returnVal; }
where #addListener executes the Runnable when the future opFuture completes, successfully or otherwise. The idiom suffers from the fact that opFuture if contains an exception, the exception itself is lost. The caller who receives returnVal gets a success future and the exception is effectively swallowed.