Program: 79900
Project: 79900
Buggy source:
/** 
 * Takes an AMRecord and writes this to the store
 * @param record The record object to store
 * @throws com.iplanet.dpro.session.exceptions.StoreException
 */
private void writeImmediate(AMRootEntity record) throws StoreException {
  boolean found=false;
  StringBuilder baseDN=new StringBuilder();
  baseDN.append(Constants.AMRECORD_NAMING_ATTR).append(Constants.EQUALS);
  baseDN.append((record).getPrimaryKey()).append(Constants.COMMA);
  baseDN.append(Constants.BASE_DN).append(Constants.COMMA).append(SystemPropertiesManager.get(SYS_PROPERTY_SESSION_HA_REPOSITORY_ROOT_DN));
  debug.error("String_Node_Str" + baseDN.toString() + "String_Node_Str"+ record.toString()+ "String_Node_Str");
  try {
    InternalSearchOperation iso=icConn.processSearch(baseDN.toString(),SearchScope.SINGLE_LEVEL,DereferencePolicy.NEVER_DEREF_ALIASES,0,0,false,Constants.FAMRECORD_FILTER,returnAttrs);
    ResultCode resultCode=iso.getResultCode();
    if (resultCode == ResultCode.SUCCESS) {
      final LocalizableMessage message=DB_ENT_P.get(baseDN);
      Log.logger.log(Level.FINE,message.toString());
      found=true;
    }
 else     if (resultCode == ResultCode.NO_SUCH_OBJECT) {
      final LocalizableMessage message=DB_ENT_NOT_P.get(baseDN);
      Log.logger.log(Level.FINE,message.toString());
    }
 else {
      final LocalizableMessage message=DB_ENT_ACC_FAIL.get(baseDN,resultCode.toString());
      Log.logger.log(Level.WARNING,message.toString());
      throw new StoreException(message.toString());
    }
  }
 catch (  DirectoryException dex) {
    final LocalizableMessage message=DB_ENT_ACC_FAIL2.get(baseDN);
    Log.logger.log(Level.WARNING,message.toString(),dex);
    throw new StoreException(message.toString(),dex);
  }
  if (found) {
    updateImmediate(record);
  }
 else {
    storeImmediate(record);
  }
}

Fixed version (ground truth):
/** 
 * Takes an AMRecord and writes this to the store
 * @param record The record object to store
 * @throws com.iplanet.dpro.session.exceptions.StoreException
 */
private void writeImmediate(AMRootEntity record) throws StoreException {
  boolean found=false;
  StringBuilder baseDN=new StringBuilder();
  baseDN.append(Constants.AMRECORD_NAMING_ATTR).append(Constants.EQUALS);
  baseDN.append((record).getPrimaryKey()).append(Constants.COMMA);
  baseDN.append(Constants.BASE_DN).append(Constants.COMMA).append(SystemPropertiesManager.get(SYS_PROPERTY_SESSION_HA_REPOSITORY_ROOT_DN));
  debug.error("String_Node_Str" + baseDN.toString() + "String_Node_Str"+ "String_Node_Str"+ record.getService()+ "String_Node_Str"+ "String_Node_Str"+ record.getOperation()+ "String_Node_Str"+ "String_Node_Str"+ record.getPrimaryKey()+ "String_Node_Str"+ "String_Node_Str"+ record.getSecondaryKey()+ "String_Node_Str"+ "String_Node_Str"+ record.getState()+ "String_Node_Str"+ "String_Node_Str"+ record.getExpDate()+ "String_Node_Str");
  try {
    InternalSearchOperation iso=icConn.processSearch(baseDN.toString(),SearchScope.SINGLE_LEVEL,DereferencePolicy.NEVER_DEREF_ALIASES,0,0,false,Constants.FAMRECORD_FILTER,returnAttrs);
    ResultCode resultCode=iso.getResultCode();
    if (resultCode == ResultCode.SUCCESS) {
      final LocalizableMessage message=DB_ENT_P.get(baseDN);
      Log.logger.log(Level.FINE,message.toString());
      found=true;
    }
 else     if (resultCode == ResultCode.NO_SUCH_OBJECT) {
      final LocalizableMessage message=DB_ENT_NOT_P.get(baseDN);
      Log.logger.log(Level.FINE,message.toString());
    }
 else {
      final LocalizableMessage message=DB_ENT_ACC_FAIL.get(baseDN,resultCode.toString());
      Log.logger.log(Level.WARNING,message.toString());
      throw new StoreException(message.toString());
    }
  }
 catch (  DirectoryException dex) {
    final LocalizableMessage message=DB_ENT_ACC_FAIL2.get(baseDN);
    Log.logger.log(Level.WARNING,message.toString(),dex);
    throw new StoreException(message.toString(),dex);
  }
  if (found) {
    updateImmediate(record);
  }
 else {
    storeImmediate(record);
  }
}