Program: 84037
Project: 84037
Buggy source:
public DatabaseChangeLog parse(String physicalChangeLogLocation,ChangeLogParameters changeLogParameters,ResourceAccessor resourceAccessor) throws ChangeLogParseException {
  DatabaseChangeLog changeLog=new DatabaseChangeLog();
  changeLog.setPhysicalFilePath(physicalChangeLogLocation);
  BufferedReader reader=null;
  try {
    reader=new BufferedReader(new InputStreamReader(openChangeLogFile(physicalChangeLogLocation,resourceAccessor)));
    StringBuffer currentSql=new StringBuffer();
    StringBuffer currentRollbackSql=new StringBuffer();
    ChangeSet changeSet=null;
    RawSQLChange change=null;
    Pattern changeSetPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern rollbackPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern stripCommentsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern splitStatementsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern endDelimiterPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runOnChangePattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runAlwaysPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern contextPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runInTransactionPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern dbmsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern failOnErrorPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    String line;
    while ((line=reader.readLine()) != null) {
      Matcher changeSetPatternMatcher=changeSetPattern.matcher(line);
      if (changeSetPatternMatcher.matches()) {
        String finalCurrentSql=StringUtils.trimToNull(currentSql.toString());
        if (changeSet != null) {
          if (finalCurrentSql == null) {
            throw new ChangeLogParseException("String_Node_Str" + changeSet.toString(false));
          }
          change.setSql(finalCurrentSql);
          if (StringUtils.trimToNull(currentRollbackSql.toString()) != null) {
            try {
              if (currentRollbackSql.toString().trim().toLowerCase().matches("String_Node_Str")) {
                changeSet.addRollbackChange(new EmptyChange());
              }
 else {
                RawSQLChange rollbackChange=new RawSQLChange();
                rollbackChange.setSql(currentRollbackSql.toString());
                changeSet.addRollbackChange(rollbackChange);
              }
            }
 catch (            UnsupportedChangeException e) {
              throw new RuntimeException(e);
            }
          }
        }
        Matcher stripCommentsPatternMatcher=stripCommentsPattern.matcher(line);
        Matcher splitStatementsPatternMatcher=splitStatementsPattern.matcher(line);
        Matcher endDelimiterPatternMatcher=endDelimiterPattern.matcher(line);
        Matcher runOnChangePatternMatcher=runOnChangePattern.matcher(line);
        Matcher runAlwaysPatternMatcher=runAlwaysPattern.matcher(line);
        Matcher contextPatternMatcher=contextPattern.matcher(line);
        Matcher runInTransactionPatternMatcher=runInTransactionPattern.matcher(line);
        Matcher dbmsPatternMatcher=dbmsPattern.matcher(line);
        Matcher failOnErrorPatternMatcher=failOnErrorPattern.matcher(line);
        boolean stripComments=parseBoolean(stripCommentsPatternMatcher,changeSet,true);
        boolean splitStatements=parseBoolean(splitStatementsPatternMatcher,changeSet,true);
        boolean runOnChange=parseBoolean(runOnChangePatternMatcher,changeSet,false);
        boolean runAlways=parseBoolean(runAlwaysPatternMatcher,changeSet,false);
        boolean runInTransaction=parseBoolean(runInTransactionPatternMatcher,changeSet,true);
        boolean failOnError=parseBoolean(failOnErrorPatternMatcher,changeSet,true);
        String endDelimiter=parseString(endDelimiterPatternMatcher);
        String context=parseString(contextPatternMatcher);
        String dbms=parseString(dbmsPatternMatcher);
        changeSet=new ChangeSet(changeSetPatternMatcher.group(2),changeSetPatternMatcher.group(1),runAlways,runOnChange,physicalChangeLogLocation,context,dbms,runInTransaction);
        changeSet.setFailOnError(failOnError);
        changeLog.addChangeSet(changeSet);
        change=new RawSQLChange();
        change.setSql(finalCurrentSql);
        change.setResourceAccessor(resourceAccessor);
        change.setSplitStatements(splitStatements);
        change.setStripComments(stripComments);
        change.setEndDelimiter(endDelimiter);
        changeSet.addChange(change);
        currentSql=new StringBuffer();
        currentRollbackSql=new StringBuffer();
      }
 else {
        if (changeSet != null) {
          Matcher rollbackMatcher=rollbackPattern.matcher(line);
          if (rollbackMatcher.matches()) {
            if (rollbackMatcher.groupCount() == 1) {
              currentRollbackSql.append(rollbackMatcher.group(1)).append("String_Node_Str");
            }
          }
 else {
            currentSql.append(line).append("String_Node_Str");
          }
        }
      }
    }
    if (changeSet != null) {
      change.setSql(StringUtils.trimToNull(currentSql.toString()));
      if (StringUtils.trimToNull(currentRollbackSql.toString()) != null) {
        try {
          if (currentRollbackSql.toString().trim().toLowerCase().matches("String_Node_Str")) {
            changeSet.addRollbackChange(new EmptyChange());
          }
 else {
            RawSQLChange rollbackChange=new RawSQLChange();
            rollbackChange.setSql(currentRollbackSql.toString());
            changeSet.addRollbackChange(rollbackChange);
          }
        }
 catch (        UnsupportedChangeException e) {
          throw new RuntimeException(e);
        }
      }
    }
  }
 catch (  IOException e) {
    throw new ChangeLogParseException(e);
  }
  return changeLog;
}

Fixed version (ground truth):
public DatabaseChangeLog parse(String physicalChangeLogLocation,ChangeLogParameters changeLogParameters,ResourceAccessor resourceAccessor) throws ChangeLogParseException {
  DatabaseChangeLog changeLog=new DatabaseChangeLog();
  changeLog.setPhysicalFilePath(physicalChangeLogLocation);
  BufferedReader reader=null;
  try {
    reader=new BufferedReader(new InputStreamReader(openChangeLogFile(physicalChangeLogLocation,resourceAccessor)));
    StringBuffer currentSql=new StringBuffer();
    StringBuffer currentRollbackSql=new StringBuffer();
    ChangeSet changeSet=null;
    RawSQLChange change=null;
    Pattern changeSetPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern rollbackPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern stripCommentsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern splitStatementsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern endDelimiterPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runOnChangePattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runAlwaysPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern contextPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern runInTransactionPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern dbmsPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    Pattern failOnErrorPattern=Pattern.compile("String_Node_Str",Pattern.CASE_INSENSITIVE);
    String line;
    while ((line=reader.readLine()) != null) {
      Matcher changeSetPatternMatcher=changeSetPattern.matcher(line);
      if (changeSetPatternMatcher.matches()) {
        String finalCurrentSql=StringUtils.trimToNull(currentSql.toString());
        if (changeSet != null) {
          if (finalCurrentSql == null) {
            throw new ChangeLogParseException("String_Node_Str" + changeSet.toString(false));
          }
          change.setSql(finalCurrentSql);
          if (StringUtils.trimToNull(currentRollbackSql.toString()) != null) {
            try {
              if (currentRollbackSql.toString().trim().toLowerCase().matches("String_Node_Str")) {
                changeSet.addRollbackChange(new EmptyChange());
              }
 else {
                RawSQLChange rollbackChange=new RawSQLChange();
                rollbackChange.setSql(currentRollbackSql.toString());
                changeSet.addRollbackChange(rollbackChange);
              }
            }
 catch (            UnsupportedChangeException e) {
              throw new RuntimeException(e);
            }
          }
        }
        Matcher stripCommentsPatternMatcher=stripCommentsPattern.matcher(line);
        Matcher splitStatementsPatternMatcher=splitStatementsPattern.matcher(line);
        Matcher endDelimiterPatternMatcher=endDelimiterPattern.matcher(line);
        Matcher runOnChangePatternMatcher=runOnChangePattern.matcher(line);
        Matcher runAlwaysPatternMatcher=runAlwaysPattern.matcher(line);
        Matcher contextPatternMatcher=contextPattern.matcher(line);
        Matcher runInTransactionPatternMatcher=runInTransactionPattern.matcher(line);
        Matcher dbmsPatternMatcher=dbmsPattern.matcher(line);
        Matcher failOnErrorPatternMatcher=failOnErrorPattern.matcher(line);
        boolean stripComments=parseBoolean(stripCommentsPatternMatcher,changeSet,true);
        boolean splitStatements=parseBoolean(splitStatementsPatternMatcher,changeSet,true);
        boolean runOnChange=parseBoolean(runOnChangePatternMatcher,changeSet,false);
        boolean runAlways=parseBoolean(runAlwaysPatternMatcher,changeSet,false);
        boolean runInTransaction=parseBoolean(runInTransactionPatternMatcher,changeSet,true);
        boolean failOnError=parseBoolean(failOnErrorPatternMatcher,changeSet,true);
        String endDelimiter=parseString(endDelimiterPatternMatcher);
        String context=parseString(contextPatternMatcher);
        String dbms=parseString(dbmsPatternMatcher);
        changeSet=new ChangeSet(changeSetPatternMatcher.group(2),changeSetPatternMatcher.group(1),runAlways,runOnChange,physicalChangeLogLocation,context,dbms,runInTransaction);
        changeSet.setFailOnError(failOnError);
        changeLog.addChangeSet(changeSet);
        change=new RawSQLChange();
        change.setSql(finalCurrentSql);
        change.setResourceAccessor(resourceAccessor);
        change.setSplitStatements(splitStatements);
        change.setStripComments(stripComments);
        change.setEndDelimiter(endDelimiter);
        changeSet.addChange(change);
        currentSql=new StringBuffer();
        currentRollbackSql=new StringBuffer();
      }
 else {
        if (changeSet != null) {
          Matcher rollbackMatcher=rollbackPattern.matcher(line);
          if (rollbackMatcher.matches()) {
            if (rollbackMatcher.groupCount() == 1) {
              currentRollbackSql.append(rollbackMatcher.group(1)).append("String_Node_Str");
            }
          }
 else {
            currentSql.append(line).append("String_Node_Str");
          }
        }
      }
    }
    if (changeSet != null) {
      change.setSql(StringUtils.trimToNull(currentSql.toString()));
      if (StringUtils.trimToNull(currentRollbackSql.toString()) != null) {
        try {
          if (currentRollbackSql.toString().trim().toLowerCase().matches("String_Node_Str")) {
            changeSet.addRollbackChange(new EmptyChange());
          }
 else {
            RawSQLChange rollbackChange=new RawSQLChange();
            rollbackChange.setSql(currentRollbackSql.toString());
            changeSet.addRollbackChange(rollbackChange);
          }
        }
 catch (        UnsupportedChangeException e) {
          throw new RuntimeException(e);
        }
      }
    }
  }
 catch (  IOException e) {
    throw new ChangeLogParseException(e);
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      IOException ignore) {
      }
    }
  }
  return changeLog;
}