I'm using Future.apply to wrap an asynchronous computation (DB access) in a Future[Unit], call it f.
I'm then passing a function g to f.map that should be executed when f completes. However g is being executed before f completes, hence before it's known if f will complete successfully or not.
Is this not a bug? The Future.map documentation says "Creates a new future by applying a function to the successful result of this future. If this future is completed with an exception then the new future will also contain this exception." So it can't be right for g to be executed before f has completed, esp. since f may throw an exception in which case g shouldn't be executed.
I'm using Scala 2.11.1.
thx,
Chris