Program: 118055
Project: 118055
Buggy source:
protected String initExpression(DbMapComponent component,ExternalDbMapEntry dbMapEntry){
  String expression=dbMapEntry.getExpression();
  if (expression != null) {
    List<Map<String,String>> itemNameList=null;
    MapExpressionParser mapParser1=new MapExpressionParser("String_Node_Str");
    itemNameList=mapParser1.parseInTableEntryLocations2(expression);
    if (itemNameList == null || itemNameList.isEmpty()) {
      MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
      itemNameList=mapParser2.parseInTableEntryLocations(expression);
    }
    for (    Map<String,String> itemNamemap : itemNameList) {
      Set<Entry<String,String>> set=itemNamemap.entrySet();
      Iterator<Entry<String,String>> ite=set.iterator();
      while (ite.hasNext()) {
        Entry<String,String> entry=ite.next();
        String columnValue=entry.getKey();
        String tableValue=entry.getValue();
        String tableNameValue=tableValue;
        String originaltableName=tableValue;
        ExternalDbMapData externalData=(ExternalDbMapData)component.getExternalData();
        final List<ExternalDbMapTable> inputTables=externalData.getInputTables();
        for (        ExternalDbMapTable inputTable : inputTables) {
          if (inputTable.getAlias() != null && inputTable.getAlias().equals(tableValue)) {
            originaltableName=inputTable.getTableName();
            tableNameValue=inputTable.getAlias();
          }
        }
        List<IConnection> inputConnections=(List<IConnection>)component.getIncomingConnections();
        if (inputConnections == null) {
          return expression;
        }
        for (        IConnection iconn : inputConnections) {
          IMetadataTable metadataTable=iconn.getMetadataTable();
          String tName=iconn.getName();
          if ((originaltableName.equals(tName) || tableValue.equals(tName)) && metadataTable != null) {
            List<IMetadataColumn> lColumn=metadataTable.getListColumns();
            String tableName=metadataTable.getTableName();
            String tableColneName=tableName;
            tableColneName=MetadataToolHelper.validateTableName(tableColneName);
            if (tableValue.contains("String_Node_Str") && tableName != null) {
              MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
              List<Map<String,String>> tableNameList=mapParser2.parseInTableEntryLocations(tableValue);
              for (              Map<String,String> tableNameMap : tableNameList) {
                Set<Entry<String,String>> setTable=tableNameMap.entrySet();
                Iterator<Entry<String,String>> iteTable=setTable.iterator();
                while (iteTable.hasNext()) {
                  Entry<String,String> tableEntry=iteTable.next();
                  String tableLabel=tableEntry.getKey();
                  String schemaValue=tableEntry.getValue();
                  if (tableLabel.equals(metadataTable.getLabel()) && tableColneName.equals(tableLabel)) {
                    tableName=tableName.replaceAll("String_Node_Str","String_Node_Str");
                    expression=expression.replaceFirst(tableValue,schemaValue + "String_Node_Str" + tableName);
                  }
                }
              }
            }
 else             if (tableName != null) {
              if (tableValue.equals(metadataTable.getLabel()) && tableColneName.equals(tableValue)) {
                tableName=tableName.replaceAll("String_Node_Str","String_Node_Str");
                expression=expression.replaceFirst(tableValue,tableName);
              }
            }
            for (            IMetadataColumn co : lColumn) {
              if (columnValue.equals(co.getLabel())) {
                String oriName=co.getOriginalDbColumnName();
                if (oriName == null || "String_Node_Str".equals(oriName)) {
                  continue;
                }
                if (expression.trim().equals(tableValue + "String_Node_Str" + oriName)) {
                  continue;
                }
                if (expression.trim().equals(originaltableName + "String_Node_Str" + oriName)) {
                  continue;
                }
                if (iconn.getLineStyle() == EConnectionType.TABLE_REF) {
                  continue;
                }
                if (oriName.trim().startsWith("String_Node_Str") && oriName.trim().endsWith("String_Node_Str")) {
                  expression=language.getLocation(tableNameValue,getHandledField(oriName));
                  continue;
                }
                oriName=oriName.replaceAll("String_Node_Str","String_Node_Str");
                expression=expression.replaceFirst("String_Node_Str" + co.getLabel(),"String_Node_Str" + oriName);
              }
            }
          }
        }
      }
    }
  }
  return expression;
}

Fixed version (ground truth):
protected String initExpression(DbMapComponent component,ExternalDbMapEntry dbMapEntry){
  String expression=dbMapEntry.getExpression();
  if (expression != null) {
    List<Map<String,String>> itemNameList=null;
    MapExpressionParser mapParser1=new MapExpressionParser("String_Node_Str");
    itemNameList=mapParser1.parseInTableEntryLocations2(expression);
    if (itemNameList == null || itemNameList.isEmpty()) {
      MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
      itemNameList=mapParser2.parseInTableEntryLocations(expression);
    }
    for (    Map<String,String> itemNamemap : itemNameList) {
      Set<Entry<String,String>> set=itemNamemap.entrySet();
      Iterator<Entry<String,String>> ite=set.iterator();
      while (ite.hasNext()) {
        Entry<String,String> entry=ite.next();
        String columnValue=entry.getKey();
        String tableValue=entry.getValue();
        String tableNameValue=tableValue;
        String originaltableName=tableValue;
        ExternalDbMapData externalData=(ExternalDbMapData)component.getExternalData();
        final List<ExternalDbMapTable> inputTables=externalData.getInputTables();
        for (        ExternalDbMapTable inputTable : inputTables) {
          if (inputTable.getAlias() != null && inputTable.getAlias().equals(tableValue)) {
            originaltableName=inputTable.getTableName();
            tableNameValue=inputTable.getAlias();
          }
        }
        List<IConnection> inputConnections=(List<IConnection>)component.getIncomingConnections();
        if (inputConnections == null) {
          return expression;
        }
        for (        IConnection iconn : inputConnections) {
          IMetadataTable metadataTable=iconn.getMetadataTable();
          String tName=iconn.getName();
          if ((originaltableName.equals(tName) || tableValue.equals(tName)) && metadataTable != null) {
            List<IMetadataColumn> lColumn=metadataTable.getListColumns();
            String tableName=metadataTable.getTableName();
            String tableColneName=tableName;
            tableColneName=MetadataToolHelper.validateTableName(tableColneName);
            if (tableValue.contains("String_Node_Str") && tableName != null) {
              MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
              List<Map<String,String>> tableNameList=mapParser2.parseInTableEntryLocations(tableValue);
              for (              Map<String,String> tableNameMap : tableNameList) {
                Set<Entry<String,String>> setTable=tableNameMap.entrySet();
                Iterator<Entry<String,String>> iteTable=setTable.iterator();
                while (iteTable.hasNext()) {
                  Entry<String,String> tableEntry=iteTable.next();
                  String tableLabel=tableEntry.getKey();
                  String schemaValue=tableEntry.getValue();
                  if (tableLabel.equals(metadataTable.getLabel()) && tableColneName.equals(tableLabel)) {
                    tableName=tableName.replaceAll("String_Node_Str","String_Node_Str");
                    expression=expression.replaceFirst(tableValue,schemaValue + "String_Node_Str" + tableName);
                  }
                }
              }
            }
 else             if (tableName != null) {
              if (tableValue.equals(metadataTable.getLabel()) && tableColneName.equals(tableValue)) {
                tableName=tableName.replaceAll("String_Node_Str","String_Node_Str");
                expression=expression.replaceFirst(tableValue,tableName);
              }
            }
            for (            IMetadataColumn co : lColumn) {
              if (columnValue.equals(co.getLabel())) {
                String oriName=co.getOriginalDbColumnName();
                if (oriName == null || "String_Node_Str".equals(oriName)) {
                  continue;
                }
                if (expression.trim().equals(tableValue + "String_Node_Str" + oriName)) {
                  continue;
                }
                if (expression.trim().equals(originaltableName + "String_Node_Str" + oriName)) {
                  continue;
                }
                if (iconn.getLineStyle() == EConnectionType.TABLE_REF) {
                  continue;
                }
                oriName=oriName.replaceAll("String_Node_Str","String_Node_Str");
                expression=expression.replaceFirst("String_Node_Str" + co.getLabel(),"String_Node_Str" + oriName);
                expression=expression.replace("String_Node_Str","String_Node_Str");
              }
            }
          }
        }
      }
    }
  }
  return expression;
}