Program: 166873
Project: 166873
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=internalConstructCompleteCopyCommandSqlVertex(sqlgGraph,schemaTable.isTemporary(),schemaTable.getSchema(),schemaTable.getTable(),vertices.getLeft());
    int numberInserted=0;
    try (Writer writer=streamSql(sqlgGraph,sql)){
      for (      Map<String,Object> keyValueMap : vertices.getRight().values()) {
        LinkedHashMap<String,Object> values=new LinkedHashMap<>();
        for (        String key : vertices.getLeft()) {
          values.put(key,keyValueMap.get(key));
        }
        writeStreamingVertex(writer,values);
        numberInserted++;
      }
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
    if (!schemaTable.isTemporary() && numberInserted > 0) {
      long endHigh;
      sql="String_Node_Str" + maybeWrapInQoutes(schemaTable.getSchema()) + "String_Node_Str"+ maybeWrapInQoutes(VERTEX_PREFIX + schemaTable.getTable() + "String_Node_Str")+ "String_Node_Str";
      if (logger.isDebugEnabled()) {
        logger.debug(sql);
      }
      try (PreparedStatement preparedStatement=con.prepareStatement(sql)){
        ResultSet resultSet=preparedStatement.executeQuery();
        resultSet.next();
        endHigh=resultSet.getLong(1);
        resultSet.close();
      }
 catch (      SQLException e) {
        throw new RuntimeException(e);
      }
      long id=endHigh - numberInserted + 1;
      for (      SqlgVertex sqlgVertex : vertices.getRight().keySet()) {
        sqlgVertex.setInternalPrimaryKey(RecordId.from(schemaTable,id++));
      }
    }
  }
}

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);
    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);
    }
  }
}