Program: 167034
Project: 167034
Buggy source:
@Override public void flushEdgeCache(SqlgGraph sqlgGraph,Map<SchemaTable,Pair<SortedSet<String>,Map<SqlgEdge,Triple<SqlgVertex,SqlgVertex,Map<String,Object>>>>> edgeCache){
  C3P0ProxyConnection con=(C3P0ProxyConnection)sqlgGraph.tx().getConnection();
  try {
    Method m=BaseConnection.class.getMethod("String_Node_Str",new Class[]{});
    Object[] arg=new Object[]{};
    CopyManager copyManager=(CopyManager)con.rawConnectionOperation(m,C3P0ProxyConnection.RAW_CONNECTION,arg);
    for (    SchemaTable schemaTable : edgeCache.keySet()) {
      Pair<SortedSet<String>,Map<SqlgEdge,Triple<SqlgVertex,SqlgVertex,Map<String,Object>>>> triples=edgeCache.get(schemaTable);
      Map<String,PropertyType> propertyTypeMap=sqlgGraph.getSchemaManager().getAllTables().get(schemaTable.getSchema() + "String_Node_Str" + SchemaManager.EDGE_PREFIX+ schemaTable.getTable());
      long endHigh;
      long numberInserted;
      try (InputStream is=mapEdgeToInputStream(propertyTypeMap,triples)){
        StringBuilder sql=new StringBuilder();
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(schemaTable.getSchema()));
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(SchemaManager.EDGE_PREFIX + schemaTable.getTable()));
        sql.append("String_Node_Str");
        for (        Triple<SqlgVertex,SqlgVertex,Map<String,Object>> triple : triples.getRight().values()) {
          int count=1;
          sql.append(maybeWrapInQoutes(triple.getLeft().getSchema() + "String_Node_Str" + triple.getLeft().getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
          sql.append("String_Node_Str");
          sql.append(maybeWrapInQoutes(triple.getMiddle().getSchema() + "String_Node_Str" + triple.getMiddle().getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
          for (          String key : triples.getLeft()) {
            if (count <= triples.getLeft().size()) {
              sql.append("String_Node_Str");
            }
            count++;
            appendKeyForStream(propertyTypeMap.get(key),sql,key);
          }
          break;
        }
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_DELIMITER);
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_QUOTE);
        sql.append("String_Node_Str");
        if (logger.isDebugEnabled()) {
          logger.debug(sql.toString());
        }
        numberInserted=copyManager.copyIn(sql.toString(),is);
        try (PreparedStatement preparedStatement=con.prepareStatement("String_Node_Str" + schemaTable.getSchema() + "String_Node_Str"+ SchemaManager.EDGE_PREFIX+ schemaTable.getTable()+ "String_Node_Str")){
          ResultSet resultSet=preparedStatement.executeQuery();
          resultSet.next();
          endHigh=resultSet.getLong(1);
          resultSet.close();
        }
         long id=endHigh - numberInserted + 1;
        for (        SqlgEdge sqlgEdge : triples.getRight().keySet()) {
          sqlgEdge.setInternalPrimaryKey(RecordId.from(schemaTable,id++));
        }
      }
     }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public void flushEdgeCache(SqlgGraph sqlgGraph,Map<MetaEdge,Pair<SortedSet<String>,Map<SqlgEdge,Triple<SqlgVertex,SqlgVertex,Map<String,Object>>>>> edgeCache){
  C3P0ProxyConnection con=(C3P0ProxyConnection)sqlgGraph.tx().getConnection();
  try {
    Method m=BaseConnection.class.getMethod("String_Node_Str",new Class[]{});
    Object[] arg=new Object[]{};
    CopyManager copyManager=(CopyManager)con.rawConnectionOperation(m,C3P0ProxyConnection.RAW_CONNECTION,arg);
    for (    MetaEdge metaEdge : edgeCache.keySet()) {
      Pair<SortedSet<String>,Map<SqlgEdge,Triple<SqlgVertex,SqlgVertex,Map<String,Object>>>> triples=edgeCache.get(metaEdge);
      Map<String,PropertyType> propertyTypeMap=sqlgGraph.getSchemaManager().getAllTables().get(metaEdge.getSchemaTable().getSchema() + "String_Node_Str" + SchemaManager.EDGE_PREFIX+ metaEdge.getSchemaTable().getTable());
      long endHigh;
      long numberInserted;
      try (InputStream is=mapEdgeToInputStream(propertyTypeMap,triples)){
        StringBuilder sql=new StringBuilder();
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(metaEdge.getSchemaTable().getSchema()));
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(SchemaManager.EDGE_PREFIX + metaEdge.getSchemaTable().getTable()));
        sql.append("String_Node_Str");
        for (        Triple<SqlgVertex,SqlgVertex,Map<String,Object>> triple : triples.getRight().values()) {
          int count=1;
          sql.append(maybeWrapInQoutes(triple.getLeft().getSchema() + "String_Node_Str" + triple.getLeft().getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
          sql.append("String_Node_Str");
          sql.append(maybeWrapInQoutes(triple.getMiddle().getSchema() + "String_Node_Str" + triple.getMiddle().getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
          for (          String key : triples.getLeft()) {
            if (count <= triples.getLeft().size()) {
              sql.append("String_Node_Str");
            }
            count++;
            appendKeyForStream(propertyTypeMap.get(key),sql,key);
          }
          break;
        }
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_DELIMITER);
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_QUOTE);
        sql.append("String_Node_Str");
        if (logger.isDebugEnabled()) {
          logger.debug(sql.toString());
        }
        numberInserted=copyManager.copyIn(sql.toString(),is);
        try (PreparedStatement preparedStatement=con.prepareStatement("String_Node_Str" + metaEdge.getSchemaTable().getSchema() + "String_Node_Str"+ SchemaManager.EDGE_PREFIX+ metaEdge.getSchemaTable().getTable()+ "String_Node_Str")){
          ResultSet resultSet=preparedStatement.executeQuery();
          resultSet.next();
          endHigh=resultSet.getLong(1);
          resultSet.close();
        }
         long id=endHigh - numberInserted + 1;
        for (        SqlgEdge sqlgEdge : triples.getRight().keySet()) {
          sqlgEdge.setInternalPrimaryKey(RecordId.from(metaEdge.getSchemaTable(),id++));
        }
      }
     }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}