Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-12982

MP fault tolerance: CDI contexts not available in @Timeout methods

XMLWordPrintable

      Say I have a @Timeout method in my application, which uses a @RequestScoped service:

      @Inject
      private MyService service;
      
      @Timeout
      public String doSomething() throws InterruptedException {
          return "Hello " + service.call();
      }
      

      The method isn't @Asynchronous, so it's supposed to be executed on the caller thread and hence the CDI contexts should be available. However, they are not:

      2018-04-03 21:16:35,976 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
      

      Clearly the @Timeout methods are always executed on a separate thread (see HystrixCommandInterceptor.initSetter):

      // Async and timeout operations use THREAD isolation strategy
      if (operation.isAsync() || operation.hasTimeout()) {
          propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
      } else {
          propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
      }
      

              rhn-engineering-rhusar Radoslav Husar
              mnovak1@redhat.com Miroslav Novak
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: