docs: protected void flush(BeanO[] theBeanOs, HashSet<BeanInstanceInfo> cmp2xBeansToFlush)
                      throws CSIException
      {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
          if (isTraceOn && tc.isDebugEnabled())
              Tr.entry(tc, "flush: num=" + (theBeanOs == null ? null : theBeanOs.length) +
                           ", cmp2x=" + (cmp2xBeansToFlush == null ? null : cmp2xBeansToFlush.size()));
  
          // Save the BeanOs processed in the following loop in an instance variable
          // so methods called from the customer callbacks can determine which beanO
          // is active on the thread.                                        d168509
  
          if (theBeanOs != null) {
              EJBThreadData threadData = EJSContainer.getThreadData(); // d630940
              boolean popCallbackBeanO = false;
              ComponentMetaData prevCMD = null;
              boolean resetCMD = false;
              ClassLoader prevClassLoader = null;
              Object origClassLoader = ThreadContextAccessor.UNCHANGED;
  
              try
              {
                  for (int i = 0; i < theBeanOs.length; i++) {
                      BeanO beanO = theBeanOs[i];
                      BeanMetaData bmd = beanO.home.beanMetaData;
  
                      if (bmd.cmpVersion != InternalConstants.CMP_VERSION_2_X ||
                          cmp2xBeansToFlush == null ||
                          cmp2xBeansToFlush.remove(beanO))
                      {
                          threadData.pushCallbackBeanO(beanO); // d168509, d630940
                          popCallbackBeanO = true;
  
                          // Update the thread CMD if it's not the same as the
                          // previous bean and this is a bean-managed bean.
                          if (bmd != prevCMD &&
                              bmd.type == InternalConstants.TYPE_BEAN_MANAGED_ENTITY)
                          {
                              if (resetCMD)
                              {
                                  cmdAccessor.endContext();
                              }
  
                              cmdAccessor.beginContext(bmd);
                              prevCMD = bmd;
                              resetCMD = true;
  
                              // Update the class loader if it's not the same as the
                              // previous bean.                         PK51366, PK83186
                              ClassLoader classLoader = bmd.ivContextClassLoader; // F85059
                              if (classLoader != prevClassLoader)
                              {
                                  prevClassLoader = classLoader;
                                  origClassLoader = EJBThreadData.svThreadContextAccessor.repushContextClassLoaderForUnprivileged(origClassLoader, classLoader);
                              }
                          }
  
                          try {
                              beanO.store();
                          } catch (RemoteException ex) {
                              FFDCFilter.processException(ex, CLASS_NAME + ".flush", "1505", this);
                              throw new CSIException("Problem storing an enlisted bean", ex);
                          }
  
                          popCallbackBeanO = false;
                          threadData.popCallbackBeanO();
                      }
                      else
                      {
                          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                              Tr.debug(tc, "Excluded from flush: " + beanO);
                      }
                  }
              } finally
              {
                  EJBThreadData.svThreadContextAccessor.popContextClassLoaderForUnprivileged(origClassLoader);
  
                  if (resetCMD)
                  {
                      cmdAccessor.endContext();
                  }
  
                  if (popCallbackBeanO)
                  {
                      threadData.popCallbackBeanO();
                  }
              }
          }
  
          if (isTraceOn && tc.isDebugEnabled())
              Tr.exit(tc, "flush");
      }