docs: @Override
      public ArrayList<ThreadContext> taskStarting() throws RejectedExecutionException {
          final boolean trace = TraceComponent.isAnyTracingEnabled();
  
          // EE Concurrency 3.3.4: All invocations to any of the proxied interface methods will fail with a
          // java.lang.IllegalStateException exception if the application component is not started or deployed.
          if (!"false".equalsIgnoreCase(execProps.get(WSContextService.REQUIRE_AVAILABLE_APP)) &&
              metaDataIdentifier != null && threadContextMgr.metadataIdentifierService.getMetaData(metaDataIdentifier) == null) {
              String taskName = execProps.get("javax.enterprise.concurrent.IDENTITY_NAME"); // ManagedTask.IDENTITY_NAME
              notAvailable(metaDataIdentifier, taskName);
          }
  
          String defaultContextTypes = execProps.get(WSContextService.DEFAULT_CONTEXT);
          final Set<String> providerNamesForDefaultContext =
                          WSContextService.UNCONFIGURED_CONTEXT_TYPES.equals(defaultContextTypes) || WSContextService.ALL_CONTEXT_TYPES.equals(defaultContextTypes)
                                          ? new HashSet<String>(threadContextMgr.threadContextProviders.keySet())
                                          : Collections.<String> emptySet();
          providerNamesForDefaultContext.removeAll(providerNamesToSkip);
  
          LinkedHashMap<ThreadContextProvider, ThreadContext> contextAppliedToThread = new LinkedHashMap<ThreadContextProvider, ThreadContext>();
          try {
              // lazily obtaining services is a privileged operation
              Map<ThreadContextProvider, ThreadContext> contextNotApplied = AccessController.doPrivileged(new PrivilegedAction<Map<ThreadContextProvider, ThreadContext>>() {
                  @Override
                  public Map<ThreadContextProvider, ThreadContext> run() {
                      Map<ThreadContextProvider, ThreadContext> contextNotApplied = new LinkedHashMap<ThreadContextProvider, ThreadContext>();
  
                      // First pass through configured context, and figure out what default context is needed
                      for (int i = 0; i < threadContext.size(); i++) {
                          String providerName = providerNames.get(i);
                          providerNamesForDefaultContext.remove(providerName);
                          contextNotApplied.put(threadContextMgr.threadContextProviders.getServiceWithException(providerName), threadContext.get(i));
                      }
  
                      // First pass through default context
                      for (String providerName : providerNamesForDefaultContext)
                          contextNotApplied.put(threadContextMgr.threadContextProviders.getServiceWithException(providerName), null);
  
                      return contextNotApplied;
                  }
              });
  
              // Make multiple passes through context that hasn't been applied until the size stops changing
              for (int count = contextNotApplied.size(), prev = count + 1; count > 0 && count < prev; prev = count, count = contextNotApplied.size())
                  for (Iterator<Entry<ThreadContextProvider, ThreadContext>> it = contextNotApplied.entrySet().iterator(); it.hasNext();) {
                      Entry<ThreadContextProvider, ThreadContext> entry = it.next();
                      ThreadContextProvider provider = entry.getKey();
                      List<ThreadContextProvider> prereqs = provider.getPrerequisites();
                      if (prereqs == null || containsAll(contextAppliedToThread, prereqs)) {
                          ThreadContext context = entry.getValue();
                          context = context == null
                                          ? provider.createDefaultThreadContext(execProps)
                                          : context.clone();
                          if (trace && tc.isDebugEnabled())
                              Tr.debug(this, tc, "taskStarting " + toString(context));
                          context.taskStarting();
                          contextAppliedToThread.put(provider, context);
                          it.remove();
                      }
                  }
  
              if (contextNotApplied.size() > 0)
                  throw new IllegalStateException(contextNotApplied.keySet().toString());
          } catch (Throwable x) {
              // In the event of failure, undo all context propagation up to this point.
              ArrayList<ThreadContext> contextToRemove = new ArrayList<ThreadContext>(contextAppliedToThread.values());
              for (int c = contextToRemove.size() - 1; c >= 0; c--)
                  try {
                      if (trace && tc.isDebugEnabled())
                          Tr.debug(this, tc, "taskStopping " + toString(contextToRemove.get(c)));
                      contextToRemove.get(c).taskStopping();
                  } catch (Throwable stopX) {
                  }
  
              if (x instanceof RejectedExecutionException)
                  throw (RejectedExecutionException) x;
              if (x instanceof RuntimeException)
                  throw (RuntimeException) x;
              if (x instanceof Error)
                  throw (Error) x;
              throw new RejectedExecutionException(x);
          }
  
          return new ArrayList<ThreadContext>(contextAppliedToThread.values());
      }