Program: 29740
Project: 29740
Buggy source:
public void postInvoke(Request request,Response response) throws IOException, ServletException {
  Context context=request.getContext();
  if (context == null) {
    ((HttpServletResponse)response.getResponse()).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,sm.getString("String_Node_Str"));
    return;
  }
  Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
  HttpServletRequest hreq=(HttpServletRequest)request.getRequest();
  Manager manager=context.getManager();
  String newsessionId=null;
  if (request instanceof org.apache.catalina.connector.Request) {
    Session sess;
    try {
      sess=((org.apache.catalina.connector.Request)request).getSessionInternal();
    }
 catch (    Exception ex) {
      sess=null;
    }
    if (sess != null) {
      newsessionId=sess.getIdInternal();
    }
  }
 else {
    HttpSession hsess;
    try {
      hsess=hreq.getSession();
    }
 catch (    Exception ex) {
      hsess=null;
    }
    if (hsess != null) {
      newsessionId=hsess.getId();
    }
  }
  log("String_Node_Str" + newsessionId);
  if (newsessionId != null) {
    if (manager instanceof PersistentManager) {
      Session session=manager.findSession(newsessionId);
      Store store=((PersistentManager)manager).getStore();
      if (store != null && session != null && session.isValid() && !isSessionStale(session,System.currentTimeMillis())) {
        store.save(session);
        ((PersistentManager)manager).removeSuper(session);
        session.recycle();
      }
 else {
        log("String_Node_Str" + store + "String_Node_Str"+ session+ "String_Node_Str"+ session.isValid()+ "String_Node_Str"+ isSessionStale(session,System.currentTimeMillis()));
      }
    }
 else {
      log("String_Node_Str" + manager);
    }
  }
}

Fixed version (ground truth):
public void postInvoke(Request request,Response response) throws IOException, ServletException {
  Context context=request.getContext();
  if (context == null) {
    ((HttpServletResponse)response.getResponse()).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,sm.getString("String_Node_Str"));
    return;
  }
  Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
  HttpServletRequest hreq=(HttpServletRequest)request.getRequest();
  Manager manager=context.getManager();
  String newsessionId=null;
  if (request instanceof org.apache.catalina.connector.Request) {
    Session sess;
    try {
      sess=((org.apache.catalina.connector.Request)request).getSessionInternal();
    }
 catch (    Exception ex) {
      sess=null;
    }
    if (sess != null) {
      newsessionId=sess.getIdInternal();
    }
  }
 else {
    HttpSession hsess;
    try {
      hsess=hreq.getSession();
    }
 catch (    Exception ex) {
      hsess=null;
    }
    if (hsess != null) {
      newsessionId=hsess.getId();
    }
  }
  log("String_Node_Str" + newsessionId);
  if (newsessionId != null) {
    if (manager instanceof PersistentManager) {
      Session session=manager.findSession(newsessionId);
      Store store=((PersistentManager)manager).getStore();
      if (store != null && session != null && session.isValid() && !isSessionStale(session,System.currentTimeMillis())) {
        store.save(session);
        ((PersistentManager)manager).removeSuper(session);
        session.recycle();
      }
 else       if (session != null) {
        log("String_Node_Str" + store + "String_Node_Str"+ session+ "String_Node_Str"+ session.isValid()+ "String_Node_Str"+ isSessionStale(session,System.currentTimeMillis()));
      }
    }
 else {
      log("String_Node_Str" + manager);
    }
  }
}