docs: public void end(Xid xid, int flags) throws XAException {
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.entry(this, tc, "end", new Object[]
              {
               ivManagedConnection,
               AdapterUtil.toString(xid), 
               AdapterUtil.getXAResourceEndFlagString(flags)
              });
  
          // if the MC marked Stale, it means the user requested a purge pool with an immediate option
          // so don't allow any work to continue.  In this case, we throw XAER_RMFAIL xa error
          // which indicates that the resource manager is not available
          if (ivManagedConnection._mcStale) {
              XAException x = new XAException(XAException.XAER_RMFAIL);;
              Tr.error(tc, "INVALID_CONNECTION");
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
                  Tr.exit(this, tc, "end", new Object[] { "MC is stale throwing XAER_RMFAIL", ivManagedConnection });
              throw x;
          }
  
          if (!xid.equals(ivXid)) { 
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) 
                  Tr.debug(this, tc, "Xid does not match.", new Object[]
                  {
                   "XAResource.start: ",
                   AdapterUtil.toString(ivXid), 
                   "XAResource.end:   ",
                   AdapterUtil.toString(xid) 
                           });
  
              XAException xaX = AdapterUtil.createXAException(
                                                              "XID_MISMATCH",
                                                              new Object[] { AdapterUtil.toString(ivXid), "end", AdapterUtil.toString(xid) },
                                                              XAException.XAER_NOTA); 
  
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                  Tr.exit(this, tc, "end", xaX);
              throw xaX;
          }
  
          try {
              ivStateManager.setState(WSStateManager.XA_END);
              ivXaRes.end(xid, flags);
              if (ivManagedConnection.helper.xaEndResetsAutoCommit)
                  ivManagedConnection.refreshCachedAutoCommit();
          } catch (TransactionException te) {
              //Exception means setState failed because it was invalid to set the state in this case
              FFDCFilter.processException(te, "com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.end", "228", this);
              Tr.error(tc, "INVALID_TX_STATE", new Object[] { "XAResource.end()", ivManagedConnection.getTransactionStateAsString() });
              try {
                  ivXaRes.rollback(xid);
              } catch (XAException eatXA) {
                  FFDCFilter.processException(eatXA, "com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.end", "236", this);
                  traceXAException(eatXA, currClass);
                  //eat the exception because we will throw the next one
              }
  
              XAException xae = AdapterUtil.createXAException(
                                                              "INVALID_TX_STATE",
                                                              new Object[] { "XAResource.end", ivManagedConnection.getTransactionStateAsString() },
                                                              XAException.XA_RBROLLBACK); 
  
              traceXAException(xae, currClass);
  
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) 
              {
                  String cId = null;
                  try {
                      cId = ivManagedConnection.mcf.getCorrelator(ivManagedConnection); 
                  } catch (SQLException x) {
                      // will just log the exception here and ignore it since its in trace
                      Tr.debug(this, tc, "got an exception trying to get the correlator in rollback during xa end fails, exception is: ", x);
                  }
  
                  if (cId != null) {
                      StringBuffer stbuf = new StringBuffer(200);
                      stbuf.append("Correlator: DB2, ID: ");
                      stbuf.append(cId);
                      stbuf.append("Transaction ID : ");
                      stbuf.append(xid);
                      stbuf.append("ROLLBACK");
                      Tr.debug(this, tc, stbuf.toString());
                  }
              }
  
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                  Tr.exit(this, tc, "end", "Exception");
              throw xae;
          } catch (XAException xae) {
              FFDCFilter.processException(xae, "com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.end", "438", this);
              checkXAException(xae); 
              // - deferred setting of state because this is not a normal case
              try {
                  ivStateManager.setState(WSStateManager.XA_END_FAIL);
              } catch (TransactionException te1) {
                  Tr.warning(tc, "DSA_INTERNAL_ERROR", new Object[] { "Error setting the state to XA_END_FAIL from ",
                                                                     ivManagedConnection.getTransactionStateAsString(), te1 });
              }
              traceXAException(xae, currClass);
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                  Tr.exit(this, tc, "end", xae); 
              throw xae; // @HMP ,moved the throw here to avoid throwing if TMFAIL
          }
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.exit(this, tc, "end");
      }