Program: 189848
Project: 189848
Buggy source:
public void importCSVToEdgesTable(File file,Character separator,Charset charset,String[] columnNames,AttributeType[] columnTypes,boolean createNewNodes){
  if (columnNames == null || columnNames.length == 0) {
    return;
  }
  if (columnTypes == null || columnNames.length != columnTypes.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  CsvReader reader=null;
  try {
    AttributeTable edges=Lookup.getDefault().lookup(AttributeController.class).getModel().getEdgeTable();
    String idColumn=null;
    String sourceColumn=null;
    String targetColumn=null;
    String typeColumn=null;
    ArrayList<AttributeColumn> columnsList=new ArrayList<AttributeColumn>();
    for (int i=0; i < columnNames.length; i++) {
      if (columnNames[i].equalsIgnoreCase("String_Node_Str")) {
        if (idColumn == null) {
          idColumn=columnNames[i];
        }
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && sourceColumn == null) {
        sourceColumn=columnNames[i];
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && targetColumn == null) {
        targetColumn=columnNames[i];
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && typeColumn == null) {
        typeColumn=columnNames[i];
      }
 else       if (edges.hasColumn(columnNames[i])) {
        columnsList.add(edges.getColumn(columnNames[i]));
      }
 else {
        columnsList.add(addAttributeColumn(edges,columnNames[i],columnTypes[i]));
      }
    }
    GraphElementsController gec=Lookup.getDefault().lookup(GraphElementsController.class);
    Graph graph=Lookup.getDefault().lookup(GraphController.class).getModel().getGraph();
    String id=null;
    Edge edge;
    String sourceId, targetId;
    Node source, target;
    String type;
    boolean directed;
    Attributes edgeAttributes;
    reader=new CsvReader(new FileInputStream(file),separator,charset);
    reader.readHeaders();
    while (reader.readRecord()) {
      sourceId=reader.get(sourceColumn);
      targetId=reader.get(targetColumn);
      if (sourceId == null || sourceId.isEmpty() || targetId == null || targetId.isEmpty()) {
        continue;
      }
      graph.readLock();
      source=graph.getNode(sourceId);
      graph.readUnlock();
      if (source == null) {
        if (createNewNodes) {
          if (source == null) {
            source=gec.createNode(null,sourceId);
          }
        }
 else {
          continue;
        }
      }
      graph.readLock();
      target=graph.getNode(targetId);
      graph.readUnlock();
      if (target == null) {
        if (createNewNodes) {
          if (target == null) {
            target=gec.createNode(null,targetId);
          }
        }
 else {
          continue;
        }
      }
      if (typeColumn != null) {
        type=reader.get(typeColumn);
        if (type != null) {
          directed=!type.equalsIgnoreCase("String_Node_Str");
        }
 else {
          directed=true;
        }
      }
 else {
        directed=true;
      }
      if (idColumn != null) {
        id=reader.get(idColumn);
        if (id == null || id.isEmpty()) {
          edge=gec.createEdge(source,target,directed);
        }
 else {
          edge=gec.createEdge(id,source,target,directed);
          if (edge == null) {
            edge=gec.createEdge(source,target,directed);
          }
        }
      }
 else {
        edge=gec.createEdge(source,target,directed);
      }
      if (edge != null) {
        edgeAttributes=edge.getEdgeData().getAttributes();
        for (        AttributeColumn column : columnsList) {
          setAttributeValue(reader.get(column.getTitle()),edgeAttributes,column);
        }
      }
 else {
        edge=graph.getEdge(source,target);
        if (edge != null) {
          String weight=reader.get(edges.getColumn(PropertiesColumn.EDGE_WEIGHT.getIndex()).getTitle());
          if (weight != null) {
            try {
              Float weightFloat=Float.parseFloat(weight);
              edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + weightFloat);
            }
 catch (            NumberFormatException numberFormatException) {
              edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + 1);
            }
          }
 else {
            edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + 1);
          }
        }
      }
    }
  }
 catch (  FileNotFoundException ex) {
    Exceptions.printStackTrace(ex);
  }
catch (  IOException ex) {
    Exceptions.printStackTrace(ex);
  }
 finally {
    reader.close();
  }
}

Fixed version (ground truth):
public void importCSVToEdgesTable(File file,Character separator,Charset charset,String[] columnNames,AttributeType[] columnTypes,boolean createNewNodes){
  if (columnNames == null || columnNames.length == 0) {
    return;
  }
  if (columnTypes == null || columnNames.length != columnTypes.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  CsvReader reader=null;
  try {
    AttributeTable edges=Lookup.getDefault().lookup(AttributeController.class).getModel().getEdgeTable();
    String idColumn=null;
    String sourceColumn=null;
    String targetColumn=null;
    String typeColumn=null;
    ArrayList<AttributeColumn> columnsList=new ArrayList<AttributeColumn>();
    for (int i=0; i < columnNames.length; i++) {
      if (columnNames[i].equalsIgnoreCase("String_Node_Str")) {
        if (idColumn == null) {
          idColumn=columnNames[i];
        }
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && sourceColumn == null) {
        sourceColumn=columnNames[i];
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && targetColumn == null) {
        targetColumn=columnNames[i];
      }
 else       if (columnNames[i].equalsIgnoreCase("String_Node_Str") && typeColumn == null) {
        typeColumn=columnNames[i];
      }
 else       if (edges.hasColumn(columnNames[i])) {
        columnsList.add(edges.getColumn(columnNames[i]));
      }
 else {
        columnsList.add(addAttributeColumn(edges,columnNames[i],columnTypes[i]));
      }
    }
    GraphElementsController gec=Lookup.getDefault().lookup(GraphElementsController.class);
    Graph graph=Lookup.getDefault().lookup(GraphController.class).getModel().getGraph();
    String id=null;
    Edge edge;
    String sourceId, targetId;
    Node source, target;
    String type;
    boolean directed;
    Attributes edgeAttributes;
    reader=new CsvReader(new FileInputStream(file),separator,charset);
    reader.setTrimWhitespace(false);
    reader.readHeaders();
    while (reader.readRecord()) {
      sourceId=reader.get(sourceColumn);
      targetId=reader.get(targetColumn);
      if (sourceId == null || sourceId.isEmpty() || targetId == null || targetId.isEmpty()) {
        continue;
      }
      graph.readLock();
      source=graph.getNode(sourceId);
      graph.readUnlock();
      if (source == null) {
        if (createNewNodes) {
          if (source == null) {
            source=gec.createNode(null,sourceId);
          }
        }
 else {
          continue;
        }
      }
      graph.readLock();
      target=graph.getNode(targetId);
      graph.readUnlock();
      if (target == null) {
        if (createNewNodes) {
          if (target == null) {
            target=gec.createNode(null,targetId);
          }
        }
 else {
          continue;
        }
      }
      if (typeColumn != null) {
        type=reader.get(typeColumn);
        if (type != null) {
          directed=!type.equalsIgnoreCase("String_Node_Str");
        }
 else {
          directed=true;
        }
      }
 else {
        directed=true;
      }
      if (idColumn != null) {
        id=reader.get(idColumn);
        if (id == null || id.isEmpty()) {
          edge=gec.createEdge(source,target,directed);
        }
 else {
          edge=gec.createEdge(id,source,target,directed);
          if (edge == null) {
            edge=gec.createEdge(source,target,directed);
          }
        }
      }
 else {
        edge=gec.createEdge(source,target,directed);
      }
      if (edge != null) {
        edgeAttributes=edge.getEdgeData().getAttributes();
        for (        AttributeColumn column : columnsList) {
          setAttributeValue(reader.get(column.getTitle()),edgeAttributes,column);
        }
      }
 else {
        edge=graph.getEdge(source,target);
        if (edge != null) {
          String weight=reader.get(edges.getColumn(PropertiesColumn.EDGE_WEIGHT.getIndex()).getTitle());
          if (weight != null) {
            try {
              Float weightFloat=Float.parseFloat(weight);
              edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + weightFloat);
            }
 catch (            NumberFormatException numberFormatException) {
              edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + 1);
            }
          }
 else {
            edge.getEdgeData().getAttributes().setValue(PropertiesColumn.EDGE_WEIGHT.getIndex(),edge.getWeight() + 1);
          }
        }
      }
    }
  }
 catch (  FileNotFoundException ex) {
    Exceptions.printStackTrace(ex);
  }
catch (  IOException ex) {
    Exceptions.printStackTrace(ex);
  }
 finally {
    reader.close();
  }
}