Program: 143845
Project: 143845
Buggy source:
/** 
 * This operation can be used to bring the database to the latest version. First it checks which scripts were already applied to the database and executes the new scripts or the updated repeatable scripts. If an existing incremental script was changed,  removed, or if a new incremental script has been added with a lower index than one that was already executed, an error is given; unless the <fromScratch> option is enabled: in that case all database objects at the end.
 * @param dryRun if true, no updates have to be performed on the database - we do a simulation of the database updateinstead of actually performing the database update.
 * @return whether updates were performed on the database
 */
public boolean updateDatabase(boolean dryRun){
  try {
    ScriptUpdates scriptUpdates=getScriptUpdates();
    if (!getIncrementalScriptsThatFailedDuringLastUpdate().isEmpty() && !scriptUpdates.hasIrregularScriptUpdates()) {
      throw new DbMaintainException("String_Node_Str" + getIncrementalScriptsThatFailedDuringLastUpdate().first() + "String_Node_Str"+ "String_Node_Str"+ getErrorScriptOptionsMessage());
    }
    if (!getRepeatableScriptsThatFailedDuringLastUpdate().isEmpty() && !scriptUpdates.hasIrregularScriptUpdates()) {
      ExecutedScript failedScript=getRepeatableScriptsThatFailedDuringLastUpdate().first();
      if (!scriptUpdates.getRegularlyAddedOrModifiedScripts().contains(new ScriptUpdate(REPEATABLE_SCRIPT_UPDATED,failedScript.getScript())) && !scriptUpdates.getRegularlyDeletedRepeatableScripts().contains(new ScriptUpdate(REPEATABLE_SCRIPT_DELETED,failedScript.getScript()))) {
        throw new DbMaintainException("String_Node_Str" + getRepeatableScriptsThatFailedDuringLastUpdate().first() + "String_Node_Str"+ "String_Node_Str");
      }
    }
    if (scriptUpdates.isEmpty()) {
      logger.info("String_Node_Str");
      return false;
    }
    boolean recreateFromScratch=false;
    if (fromScratchEnabled && isInitialDatabaseUpdate()) {
      logger.info("String_Node_Str");
      recreateFromScratch=true;
    }
    if (scriptUpdates.hasIrregularScriptUpdates()) {
      if (fromScratchEnabled) {
        logger.info("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getIrregularScriptUpdates()));
        recreateFromScratch=true;
      }
 else {
        throw new DbMaintainException("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getIrregularScriptUpdates()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      }
    }
    if (recreateFromScratch) {
      if (baseLineRevision != null) {
        throw new DbMaintainException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
      }
      logger.info("String_Node_Str");
      if (!dryRun) {
        dbClearer.clearDatabase();
        executeScripts(scriptRepository.getAllUpdateScripts());
      }
    }
 else {
      logger.info("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getRegularScriptUpdates()));
      if (!dryRun) {
        if (disableConstraints) {
          constraintsDisabler.disableConstraints();
        }
        if (cleanDb) {
          dbCleaner.cleanDatabase();
        }
        executeScriptUpdates(scriptUpdates.getRegularlyAddedPatchScripts());
        executeScriptUpdates(scriptUpdates.getRegularlyAddedOrModifiedScripts());
        removeDeletedRepeatableScriptsFromExecutedScripts(scriptUpdates.getRegularlyDeletedRepeatableScripts());
        performRegularScriptRenamesInExecutedScripts(scriptUpdates.getRegularlyRenamedScripts());
      }
    }
    if (scriptUpdates.noUpdatesOtherThanRepeatableScriptDeletionsOrRenames()) {
      logger.info("String_Node_Str");
      return false;
    }
    if (!dryRun) {
      executePostprocessingScripts();
      if (disableConstraints) {
        constraintsDisabler.disableConstraints();
      }
      if (cleanDb) {
        dbCleaner.cleanDatabase();
      }
      if (updateSequences) {
        sequenceUpdater.updateSequences();
      }
      logger.info("String_Node_Str");
    }
    return true;
  }
  finally {
    sqlHandler.closeAllConnections();
  }
}

Fixed version (ground truth):
/** 
 * This operation can be used to bring the database to the latest version. First it checks which scripts were already applied to the database and executes the new scripts or the updated repeatable scripts. If an existing incremental script was changed,  removed, or if a new incremental script has been added with a lower index than one that was already executed, an error is given; unless the <fromScratch> option is enabled: in that case all database objects at the end.
 * @param dryRun if true, no updates have to be performed on the database - we do a simulation of the database updateinstead of actually performing the database update.
 * @return whether updates were performed on the database
 */
public boolean updateDatabase(boolean dryRun){
  try {
    ScriptUpdates scriptUpdates=getScriptUpdates();
    if (!getIncrementalScriptsThatFailedDuringLastUpdate().isEmpty() && !scriptUpdates.hasIrregularScriptUpdates()) {
      throw new DbMaintainException("String_Node_Str" + getIncrementalScriptsThatFailedDuringLastUpdate().first() + "String_Node_Str"+ "String_Node_Str"+ getErrorScriptOptionsMessage());
    }
    if (!getRepeatableScriptsThatFailedDuringLastUpdate().isEmpty() && !scriptUpdates.hasIrregularScriptUpdates()) {
      ExecutedScript failedScript=getRepeatableScriptsThatFailedDuringLastUpdate().first();
      if (!scriptUpdates.getRegularlyAddedOrModifiedScripts().contains(new ScriptUpdate(REPEATABLE_SCRIPT_UPDATED,failedScript.getScript())) && !scriptUpdates.getRegularlyDeletedRepeatableScripts().contains(new ScriptUpdate(REPEATABLE_SCRIPT_DELETED,failedScript.getScript()))) {
        throw new DbMaintainException("String_Node_Str" + getRepeatableScriptsThatFailedDuringLastUpdate().first() + "String_Node_Str"+ "String_Node_Str");
      }
    }
    if (scriptUpdates.isEmpty()) {
      logger.info("String_Node_Str");
      return false;
    }
    boolean recreateFromScratch=false;
    if (fromScratchEnabled && isInitialDatabaseUpdate()) {
      logger.info("String_Node_Str");
      recreateFromScratch=true;
    }
    if (scriptUpdates.hasIrregularScriptUpdates()) {
      if (fromScratchEnabled) {
        logger.info("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getIrregularScriptUpdates()));
        recreateFromScratch=true;
      }
 else {
        throw new DbMaintainException("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getIrregularScriptUpdates()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      }
    }
    if (recreateFromScratch) {
      if (baseLineRevision != null) {
        throw new DbMaintainException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
      }
      logger.info("String_Node_Str");
      if (!dryRun) {
        dbClearer.clearDatabase();
        executedScriptInfoSource.clearAllExecutedScripts();
        executeScripts(scriptRepository.getAllUpdateScripts());
      }
    }
 else {
      logger.info("String_Node_Str" + scriptUpdatesFormatter.formatScriptUpdates(scriptUpdates.getRegularScriptUpdates()));
      if (!dryRun) {
        if (disableConstraints) {
          constraintsDisabler.disableConstraints();
        }
        if (cleanDb) {
          dbCleaner.cleanDatabase();
        }
        executeScriptUpdates(scriptUpdates.getRegularlyAddedPatchScripts());
        executeScriptUpdates(scriptUpdates.getRegularlyAddedOrModifiedScripts());
        removeDeletedRepeatableScriptsFromExecutedScripts(scriptUpdates.getRegularlyDeletedRepeatableScripts());
        performRegularScriptRenamesInExecutedScripts(scriptUpdates.getRegularlyRenamedScripts());
      }
    }
    if (scriptUpdates.noUpdatesOtherThanRepeatableScriptDeletionsOrRenames()) {
      logger.info("String_Node_Str");
      return false;
    }
    if (!dryRun) {
      executePostprocessingScripts();
      if (disableConstraints) {
        constraintsDisabler.disableConstraints();
      }
      if (cleanDb) {
        dbCleaner.cleanDatabase();
      }
      if (updateSequences) {
        sequenceUpdater.updateSequences();
      }
      logger.info("String_Node_Str");
    }
    return true;
  }
  finally {
    sqlHandler.closeAllConnections();
  }
}