code: @SuppressWarnings({ "rawtypes" })
      private static void resetCheckedInternal(Object token, Exception firstException) throws ThreadIdentityException {
          Exception cachedException = firstException;
          if (threadIdentityServices.isEmpty() == false || j2cIdentityServices.isEmpty() == false) {
              if (!checkForRecursionAndSet()) {
                  try {
                      if (token != null) {
                          Map tokenMap = (Map) token;
                          int size = tokenMap.size();
                          if (size > 0) {
                              @SuppressWarnings("unchecked")
                              List<Map.Entry> identityServicesToTokensMap = new ArrayList<Map.Entry>(tokenMap.entrySet());
  
                              for (int idx = size - 1; idx >= 0; idx--) {
                                  Map.Entry entry = identityServicesToTokensMap.get(idx);
                                  Object identityService = entry.getKey();
                                  Object identityServiceToken = entry.getValue();
                                  try {
                                      if (identityService instanceof ThreadIdentityService) {
                                          ((ThreadIdentityService) identityService).reset(identityServiceToken);
                                      } else if (identityService instanceof J2CIdentityService) {
                                          ((J2CIdentityService) identityService).reset(identityServiceToken);
                                      }
                                  } catch (Exception e) {
                                      com.ibm.ws.ffdc.FFDCFilter.processException(e, thisClass, "385");
                                      if (cachedException == null)
                                      {
                                          cachedException = e;
                                      }
                                  }
                              }
                          }
                      }
                  } finally {
                      resetRecursionCheck();
                      if (cachedException != null)
                      {
                          throw new ThreadIdentityException(cachedException);
                      }
                  }
              }
          }
      }
docs: Reset the identity on the thread.
  
  @param token The token returned by a previous call to set the thread identity.
  The token represents the previous identity on the thread.
  @param firstException This is the first exception that may have been thrown by set()
  @throws ThreadIdentityException