Program: 167059
Project: 167059
Buggy source:
static void addLabelToEdge(SqlgGraph sqlgGraph,String schema,String prefixedTable,boolean in,SchemaTable foreignKey){
  BatchManager.BatchModeType batchModeType=flushAndSetTxToNone(sqlgGraph);
  try {
    GraphTraversalSource traversalSource=GraphTraversalSource.build().with(TopologyStrategy.build().selectFrom(SchemaManager.SQLG_SCHEMA_SCHEMA_TABLES).create()).create(sqlgGraph);
    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");
    Vertex schemaVertex=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())).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 vertexTable;
    if (in) {
      vertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.IN_VERTEX_COLUMN_END.length());
    }
 else {
      vertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.OUT_VERTEX_COLUMN_END.length());
    }
    List<Vertex> foreignKeyVertices=traversalSource.V(schemaVertex).out(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",vertexTable).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=GraphTraversalSource.build().with(TopologyStrategy.build().selectFrom(SchemaManager.SQLG_SCHEMA_SCHEMA_TABLES).create()).create(sqlgGraph);
    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");
    Vertex schemaVertex=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_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 vertexTable;
    if (in) {
      vertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.IN_VERTEX_COLUMN_END.length());
    }
 else {
      vertexTable=foreignKey.getTable().substring(0,foreignKey.getTable().length() - SchemaManager.OUT_VERTEX_COLUMN_END.length());
    }
    List<Vertex> foreignKeyVertices=traversalSource.V(schemaVertex).out(SchemaManager.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE).has("String_Node_Str",vertexTable).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);
  }
}