excilys/androidannotations — pull request #727 by tbruyelle (2013-09-17 09:49:28+00:00)
Title: Propagate exceptions for submitted/scheduled tasks

Fix improvement for #646

For remind, the goal of #646 was to stop catching exception in `@Backgound` annotated methods, in order to let the user deals with it.

First shot was to simply remove the try/catch blocks, but as discussed [here](https://github.com/excilys/androidannotations/pull/677#issuecomment-21859232), there is a problem because `ExecutorService.submit/schedule` doesn't propagate exception during executions. This is *by design*. As a result, exceptions thrown are not logged and not visible.

To handle that, I suggest a solution :
Call `futur.get()` (in another thread pool) to check if an exception occurred during execution. If yes then throw it so it could be caught by the system.

I admit it looks like a nasty trick, but I didn't find a better solution. If someone has, I will be happy to read it.