I am new to java.util.concurrent package and wrote a simple method which fetches some rows from DB. I made sure that my DB call throws back an exception to handle it. But i am not seeing the exception propagating back to me. Instead call to my method is returning null.
Can some one help me in this case? Here is my sample method call
private FutureTask<List<ConditionFact>> getConditionFacts(final Member member) throws Exception {
FutureTask<List<ConditionFact>> task = new FutureTask<List<ConditionFact>>(new Callable<List<ConditionFact>>() {
public List<ConditionFact> call() throws Exception {
return saeFactDao.findConditionFactsByMember(member);
}
});
taskExecutor.execute(task);
return task;
}
I googled and found some pages around it. But don’t see any concrete solutions for it. Experts please help….
The taskExecutor is object of org.springframework.core.task.TaskExecutor
The FutureTask will execute in a new thread and, if an exception occurs, will store it in an instance field. It’s only when you’ll ask the result of the execution that you will get the exception, wrapped inside an
ExecutionException: