Program: 167053
Project: 167053
Buggy source:
static void addLabelToEdge(SqlgGraph sqlgGraph,String schema,String prefixedTable,boolean in,SchemaTable foreignKey){
  BatchManager.BatchModeType batchModeType=flushAndSetTxToNone(sqlgGraph);
  try {
    GraphTraversalSource traversalSource=sqlgGraph.traversal().withStrategies(TopologyStrategy.build().selectFrom(SchemaManager.SQLG_SCHEMA_SCHEMA_TABLES).create());
    List<Vertex> schemas=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_SCHEMA).has("String_Node_Str",schema).toList();
    Preconditions.checkState(!schemas.isEmpty(),"String_Node_Str" + schema + "String_Node_Str");
    Preconditions.checkState(schemas.size() == 1,"String_Node_Str" + schema + "String_Node_Str");
    String foreignKeySchema=foreignKey.getSchema();
    schemas=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_SCHEMA).has("String_Node_Str",foreignKeySchema).toList();
    Preconditions.checkState(!schemas.isEmpty(),"String_Node_Str" + foreignKeySchema + "String_Node_Str");
    Preconditions.checkState(schemas.size() == 1,"String_Node_Str" + foreignKeySchema + "String_Node_Str");
    Vertex foreignKeySchemaVertex=schemas.get(0);
    Preconditions.checkState(prefixedTable.startsWith(SchemaManager.EDGE_PREFIX));
    List<Vertex> edgeVertices=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_EDGE_LABEL).has("String_Node_Str",prefixedTable.substring(SchemaManager.EDGE_PREFIX.length())).as("String_Node_Str").in(in ? SchemaManager.SQLG_SCHEMA_OUT_EDGES_EDGE : SchemaManager.SQLG_SCHEMA_IN_EDGES_EDGE).in(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",schema).<Vertex>select("String_Node_Str").dedup().toList();
    Preconditions.checkState(!edgeVertices.isEmpty(),"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(edgeVertices.size() == 1,"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Vertex edgeVertex=edgeVertices.get(0);
    String foreignKeyVertexTable;
    if (in) {
      foreignKeyVertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.IN_VERTEX_COLUMN_END.length());
    }
 else {
      foreignKeyVertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.OUT_VERTEX_COLUMN_END.length());
    }
    List<Vertex> foreignKeyVertices=traversalSource.V(foreignKeySchemaVertex).out(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",foreignKeyVertexTable).toList();
    Preconditions.checkState(!foreignKeyVertices.isEmpty(),"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(foreignKeyVertices.size() == 1,"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(prefixedTable.startsWith(SchemaManager.EDGE_PREFIX));
    Vertex foreignKeyVertex=foreignKeyVertices.get(0);
    if (in) {
      foreignKeyVertex.addEdge(SchemaManager.SQLG_SCHEMA_IN_EDGES_EDGE,edgeVertex);
    }
 else {
      foreignKeyVertex.addEdge(SchemaManager.SQLG_SCHEMA_OUT_EDGES_EDGE,edgeVertex);
    }
  }
  finally {
    sqlgGraph.tx().batchMode(batchModeType);
  }
}

Fixed version (ground truth):
static void addLabelToEdge(SqlgGraph sqlgGraph,String schema,String prefixedTable,boolean in,SchemaTable foreignKey){
  BatchManager.BatchModeType batchModeType=flushAndSetTxToNone(sqlgGraph);
  try {
    GraphTraversalSource traversalSource=sqlgGraph.traversal().withStrategies(TopologyStrategy.build().selectFrom(SchemaManager.SQLG_SCHEMA_SCHEMA_TABLES).create());
    List<Vertex> schemas=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_SCHEMA).has("String_Node_Str",schema).toList();
    Preconditions.checkState(!schemas.isEmpty(),"String_Node_Str" + schema + "String_Node_Str");
    Preconditions.checkState(schemas.size() == 1,"String_Node_Str" + schema + "String_Node_Str");
    String foreignKeySchema=foreignKey.getSchema();
    schemas=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_SCHEMA).has("String_Node_Str",foreignKeySchema).toList();
    Preconditions.checkState(!schemas.isEmpty(),"String_Node_Str" + foreignKeySchema + "String_Node_Str");
    Preconditions.checkState(schemas.size() == 1,"String_Node_Str" + foreignKeySchema + "String_Node_Str");
    Vertex foreignKeySchemaVertex=schemas.get(0);
    Preconditions.checkState(prefixedTable.startsWith(SchemaManager.EDGE_PREFIX));
    List<Vertex> edgeVertices=traversalSource.V().hasLabel(SchemaManager.SQLG_SCHEMA + "String_Node_Str" + SchemaManager.SQLG_SCHEMA_EDGE_LABEL).has("String_Node_Str",prefixedTable.substring(SchemaManager.EDGE_PREFIX.length())).as("String_Node_Str").in(SchemaManager.SQLG_SCHEMA_OUT_EDGES_EDGE).in(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",schema).<Vertex>select("String_Node_Str").dedup().toList();
    Preconditions.checkState(!edgeVertices.isEmpty(),"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(edgeVertices.size() == 1,"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Vertex edgeVertex=edgeVertices.get(0);
    String foreignKeyVertexTable;
    if (in) {
      foreignKeyVertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.IN_VERTEX_COLUMN_END.length());
    }
 else {
      foreignKeyVertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.OUT_VERTEX_COLUMN_END.length());
    }
    List<Vertex> foreignKeyVertices=traversalSource.V(foreignKeySchemaVertex).out(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",foreignKeyVertexTable).toList();
    Preconditions.checkState(!foreignKeyVertices.isEmpty(),"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(foreignKeyVertices.size() == 1,"String_Node_Str" + foreignKey.toString() + "String_Node_Str");
    Preconditions.checkState(prefixedTable.startsWith(SchemaManager.EDGE_PREFIX));
    Vertex foreignKeyVertex=foreignKeyVertices.get(0);
    if (in) {
      foreignKeyVertex.addEdge(SchemaManager.SQLG_SCHEMA_IN_EDGES_EDGE,edgeVertex);
    }
 else {
      foreignKeyVertex.addEdge(SchemaManager.SQLG_SCHEMA_OUT_EDGES_EDGE,edgeVertex);
    }
  }
  finally {
    sqlgGraph.tx().batchMode(batchModeType);
  }
}