Program: 167066
Project: 167066
Buggy source:
/** 
 * flushes the cache via the copy command. first writes the
 * @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 Map<SchemaTable,Pair<Long,Long>> flushVertexCache(SqlgGraph sqlgGraph,Map<SchemaTable,Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>>> vertexCache){
  Map<SchemaTable,Pair<Long,Long>> verticesRanges=new LinkedHashMap<>();
  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 : vertexCache.keySet()) {
      Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>> vertices=vertexCache.get(schemaTable);
      long endHigh;
      long numberInserted;
      try (InputStream is=mapToLabeledVertex_InputStream(vertices)){
        StringBuffer sql=new StringBuffer();
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(schemaTable.getSchema()));
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + schemaTable.getTable()));
        sql.append("String_Node_Str");
        if (vertices.getLeft().isEmpty()) {
          sqlgGraph.getSchemaManager().ensureColumnExist(schemaTable.getSchema(),SchemaManager.VERTEX_PREFIX + schemaTable.getTable(),ImmutablePair.of("String_Node_Str",PropertyType.from(0)));
          sql.append(maybeWrapInQoutes("String_Node_Str"));
        }
 else {
          int count=1;
          for (          String key : vertices.getLeft()) {
            if (count > 1 && count <= vertices.getLeft().size()) {
              sql.append("String_Node_Str");
            }
            count++;
            sql.append(maybeWrapInQoutes(key));
          }
        }
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_SEPARATOR);
        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.VERTEX_PREFIX+ schemaTable.getTable()+ "String_Node_Str")){
          ResultSet resultSet=preparedStatement.executeQuery();
          resultSet.next();
          endHigh=resultSet.getLong(1);
          resultSet.close();
        }
         long id=endHigh - numberInserted + 1;
        for (        SqlgVertex sqlgVertex : vertices.getRight().keySet()) {
          sqlgVertex.setInternalPrimaryKey(RecordId.from(schemaTable,id++));
        }
      }
       verticesRanges.put(schemaTable,Pair.of(endHigh - numberInserted + 1,endHigh));
    }
    return verticesRanges;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * flushes the cache via the copy command. first writes the
 * @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 Map<SchemaTable,Pair<Long,Long>> flushVertexCache(SqlgGraph sqlgGraph,Map<SchemaTable,Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>>> vertexCache){
  Map<SchemaTable,Pair<Long,Long>> verticesRanges=new LinkedHashMap<>();
  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 : vertexCache.keySet()) {
      Pair<SortedSet<String>,Map<SqlgVertex,Map<String,Object>>> vertices=vertexCache.get(schemaTable);
      long endHigh;
      long numberInserted;
      try (InputStream is=mapToLabeledVertex_InputStream(vertices)){
        StringBuffer sql=new StringBuffer();
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(schemaTable.getSchema()));
        sql.append("String_Node_Str");
        sql.append(maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + schemaTable.getTable()));
        sql.append("String_Node_Str");
        if (vertices.getLeft().isEmpty()) {
          sqlgGraph.getSchemaManager().ensureColumnExist(schemaTable.getSchema(),SchemaManager.VERTEX_PREFIX + schemaTable.getTable(),ImmutablePair.of(COPY_DUMMY,PropertyType.from(0)));
          sql.append(maybeWrapInQoutes(COPY_DUMMY));
        }
 else {
          int count=1;
          for (          String key : vertices.getLeft()) {
            if (count > 1 && count <= vertices.getLeft().size()) {
              sql.append("String_Node_Str");
            }
            count++;
            sql.append(maybeWrapInQoutes(key));
          }
        }
        sql.append("String_Node_Str");
        sql.append("String_Node_Str");
        sql.append(COPY_COMMAND_SEPARATOR);
        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.VERTEX_PREFIX+ schemaTable.getTable()+ "String_Node_Str")){
          ResultSet resultSet=preparedStatement.executeQuery();
          resultSet.next();
          endHigh=resultSet.getLong(1);
          resultSet.close();
        }
         long id=endHigh - numberInserted + 1;
        for (        SqlgVertex sqlgVertex : vertices.getRight().keySet()) {
          sqlgVertex.setInternalPrimaryKey(RecordId.from(schemaTable,id++));
        }
      }
       verticesRanges.put(schemaTable,Pair.of(endHigh - numberInserted + 1,endHigh));
    }
    return verticesRanges;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}