docs: BackedSession retrieveSession(String id, int versionId, BackedSession inMemSess) {
          //create local variable - JIT performance improvement
          final boolean isTraceOn = com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled();
          boolean useTheInMemSess = false;
          long lastAccessedTimeOnLocalCopy = 0;
          if (inMemSess != null && inMemSess.isValid()) {
              lastAccessedTimeOnLocalCopy = inMemSess.getCurrentAccessTime();
          }
          long lastAccessTimeOnBackendCopy = 0;
  
          if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
              StringBuffer sb = new StringBuffer("{").append(id).append(",").append(versionId).append(",").append(lastAccessedTimeOnLocalCopy).append("}");
              LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[RETRIEVE_SESSION], sb.toString());
          }
          BackedSession sess = null;
          sess = (BackedSession) superGet(id);
          if (sess != null) {
              if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                  LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[RETRIEVE_SESSION], "Found session in local cache.");
              }
              return sess;
          }
  
          if (isPresentInRecentlyInvalidatedList(id)) {
              if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                  LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[RETRIEVE_SESSION], "null - Id present in recently invalidated list.");
              }
              return null;
          }
  
          sess = readFromExternal(id);
  
          //Make sure only one copy of session object is in cache
          //and the same copy is returned to concurrent requests
          //entering here.
          boolean cacheIdUpdate = false;
          if (sess != null) {
              lastAccessTimeOnBackendCopy = sess.getCurrentAccessTime();
              BackedSession thrownOutSess = null;
              synchronized (this) {
                  BackedSession ds = (BackedSession) superGet(id);
                  if (ds == null) {
                      if (!_isApplicationSessionHashMap) { // don't update versionId for appSessions as this could update it twice.  We don't have a good solution for appSessions yet.
                          cacheIdUpdate = true;
                      }
                      //If it is Time-based or manual writes, we could have not updated the backend yet.  If we retrieve an
                      //old version from the backend, have another server update the backend with this version #, then we
                      //update the backend with this version #, both servers could think that they have a valid id in their
                      //local cache.  We want to do the lastAccessTimes check for endOfService writes so that we don't thrash
                      //on a failover.
                      //PK47847 allows us to check the lastAccessTimes for !EOS writes.  The customer should be on one machine or have their times set to be identical.
                      //before we always updated the cache ... must maintain behavior
                      if (_smc.getEnableEOSWrite() || _smc.getOptimizeCacheIdIncrements()) {
                          if (lastAccessedTimeOnLocalCopy == lastAccessTimeOnBackendCopy ||
                                  ((lastAccessedTimeOnLocalCopy > lastAccessTimeOnBackendCopy) && _smc.getOptimizeCacheIdIncrements())) {
                              //use the in-memory copy && don't update the cache
                              //when the lastAccessedTimeOnLocalCopy>lastAccessTimeOnBackendCopy we
                              //only want to use the in-memory copy (even when using EOS) when the property is set
                              if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                                  LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[RETRIEVE_SESSION], "Using in-memory session instead of retrieved.");
                              }
                              cacheIdUpdate = false;
                              sess = inMemSess;
                              useTheInMemSess = true;
                          }
                      }
                      thrownOutSess = (BackedSession) superPut(id, sess);
                      //update to current version ... if cacheIdUpdate is true, we will increment from this value
                      sess.setVersion(versionId);
                      sess.setIsNew(false);
                  } //end if (ds=null)
                  else {
                      //Make sure we have only one instance
                      sess = ds;
                  }
              }
              if (thrownOutSess != null && !useTheInMemSess)
                  this.passivateSession(thrownOutSess);
          } else {
              if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                  LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[RETRIEVE_SESSION], "Session is not found on backend");
              }
              return null;
          }
  
          synchronized (sess) {
              long nowTime = System.currentTimeMillis();
              long prevLastAccess = sess.getCurrentAccessTime(); // cmd 200713
  
              //Update the row with current timestamp
              int rowCount = -1;
              if (prevLastAccess < nowTime) {
                  rowCount = updateLastAccessTime(sess, nowTime);
              } else {
                  //if this request was served by an another clone on a different
                  //machine then it is possible that nowTime of system is less
                  //than lastaccesstime in session, if there  is time diff between
                  //boxes
                  nowTime = prevLastAccess;
              }
  
              if (rowCount == 0) {
                  superRemove(sess.getId());
                  sess = null;
                  if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
                      LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[RETRIEVE_SESSION], "null - updateLastAccessTime failed.");
                  }
                  return sess;
              }
  
              sess.updateLastAccessTime(nowTime);
              sess.setLastWriteLastAccessTime(nowTime);
  
              sess.initSession(_iStore);
              if ((!useTheInMemSess) &&
                      (sess.getSwappableListeners(BackedSession.HTTP_SESSION_ACTIVATION_LISTENER) ||
                      SessionManagerConfig.is_zOS())) { // cmd 420285 must call for zOS to re-establish affinity
                  getStoreCallback().sessionDidActivate(sess); // call activation listeners
              }
          }
  
          if (cacheIdUpdate) {
              updateCacheId(sess);
          }
          if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
              LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[RETRIEVE_SESSION], "session found");
          }
          return sess;
      }