Program: 166876
Project: 166876
Buggy source:
/** 
 * flushes the cache via the copy command.
 * @param vertexCache A rather complex object.The map's key is the vertex being cached. The Triple holds, 1) The in labels 2) The out labels 3) The properties as a map of key values
 */
@Override public void flushVertexCache(SqlgGraph sqlgGraph,Map<SchemaTable,Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>>> vertexCache){
  Connection con=sqlgGraph.tx().getConnection();
  for (  SchemaTable schemaTable : vertexCache.keySet()) {
    Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>> vertices=vertexCache.get(schemaTable);
    String sql="String_Node_Str" + maybeWrapInQoutes(schemaTable.getSchema()) + "String_Node_Str"+ maybeWrapInQoutes(VERTEX_PREFIX + schemaTable.getTable() + "String_Node_Str")+ "String_Node_Str"+ vertices.getRight().values().size()+ "String_Node_Str";
    if (logger.isDebugEnabled()) {
      logger.debug(sql);
    }
    List<Long> ids=new LinkedList<>();
    try (PreparedStatement preparedStatement=con.prepareStatement(sql)){
      ResultSet resultSet=preparedStatement.executeQuery();
      while (resultSet.next()) {
        ids.add(resultSet.getLong(1));
      }
      resultSet.close();
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
    Iterator<Long> it=ids.iterator();
    sql=internalConstructCompleteCopyCommandSqlVertex(sqlgGraph,schemaTable.isTemporary(),schemaTable.getSchema(),schemaTable.getTable(),vertices.getLeft());
    try (Writer writer=streamSql(sqlgGraph,sql)){
      for (      SqlgVertex sqlgVertex : vertices.getRight().keySet()) {
        Map<String,Object> keyValueMap=vertices.getRight().get(sqlgVertex);
        long id=it.next();
        sqlgVertex.setInternalPrimaryKey(RecordId.from(schemaTable,id));
        LinkedHashMap<String,Object> values=new LinkedHashMap<>();
        values.put("String_Node_Str",id);
        for (        String key : vertices.getLeft()) {
          values.put(key,keyValueMap.get(key));
        }
        writeStreamingVertex(writer,values);
      }
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
}

Fixed version (ground truth):
/** 
 * flushes the cache via the copy command.
 * @param vertexCache A rather complex object.The map's key is the vertex being cached. The Triple holds, 1) The in labels 2) The out labels 3) The properties as a map of key values
 */
@Override public void flushVertexCache(SqlgGraph sqlgGraph,Map<SchemaTable,Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>>> vertexCache){
  Connection con=sqlgGraph.tx().getConnection();
  for (  SchemaTable schemaTable : vertexCache.keySet()) {
    Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>> vertices=vertexCache.get(schemaTable);
    List<Long> ids=new LinkedList<>();
    if (!schemaTable.isTemporary()) {
      String sql="String_Node_Str" + maybeWrapInQoutes(schemaTable.getSchema()) + "String_Node_Str"+ maybeWrapInQoutes(VERTEX_PREFIX + schemaTable.getTable() + "String_Node_Str")+ "String_Node_Str"+ vertices.getRight().values().size()+ "String_Node_Str";
      if (logger.isDebugEnabled()) {
        logger.debug(sql);
      }
      try (PreparedStatement preparedStatement=con.prepareStatement(sql)){
        ResultSet resultSet=preparedStatement.executeQuery();
        while (resultSet.next()) {
          ids.add(resultSet.getLong(1));
        }
        resultSet.close();
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
    }
    Iterator<Long> it=ids.iterator();
    String sql=internalConstructCompleteCopyCommandSqlVertex(sqlgGraph,schemaTable.isTemporary(),schemaTable.getSchema(),schemaTable.getTable(),!schemaTable.isTemporary(),vertices.getLeft());
    try (Writer writer=streamSql(sqlgGraph,sql)){
      for (      SqlgVertex sqlgVertex : vertices.getRight().keySet()) {
        Map<String,Object> keyValueMap=vertices.getRight().get(sqlgVertex);
        LinkedHashMap<String,Object> values=new LinkedHashMap<>();
        if (!schemaTable.isTemporary()) {
          long id=it.next();
          sqlgVertex.setInternalPrimaryKey(RecordId.from(schemaTable,id));
          values.put("String_Node_Str",id);
        }
        for (        String key : vertices.getLeft()) {
          values.put(key,keyValueMap.get(key));
        }
        writeStreamingVertex(writer,values);
      }
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
}