title: Custom AsyncUncaughtExceptionHandler
body: <p>Using the following configuration for @Async methods :</p>
  
  <pre><code>@Configuration
  @EnableAsync
  public class AsyncConfig implements AsyncConfigurer {
  
      @Override
      public Executor getAsyncExecutor() {
          //Just to experiment
          return new SimpleAsyncTaskExecutor();
      }
  
      @Override
      public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
          return new CustomAsyncExceptionHandler();
      }
  }
  </code></pre>
  
  <p>Is there a way to "get" the ability to autowire (or similar) Services ?</p>
  
  <p>I'd like to use such Services to record errors in database and use common services.</p>
  
  <p>Non working sample :</p>
  
  <pre><code>@Component //seems pointless
  public class CustomAsyncExceptionHandler extends ServiceCommons implements AsyncUncaughtExceptionHandler {
      protected Logger LOG = LoggerFactory.getLogger(this.getClass());
  
      @Autowired
      private MyService myService; //always null
  
      @Override
      public void handleUncaughtException(Throwable throwable, Method method, Object... obj) {
          //null pointer !
          myService.doSomething(throwable);
      }
  }
  </code></pre>
  
  <p>When using not in @Async methods, @ControllerAdvice global exception handler allows @Autowired fields. Why not in this case ? Is this because of async thread management ?</p>