You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to delete concepts as you iterate over them will fail with a ConcurrentModificationException:
try (Grakn.Session session = grakn.session(database, Arguments.Session.Type.DATA)) {
try (Grakn.Transaction tx = session.transaction(Arguments.Transaction.Type.WRITE)) {
tx.query().insert(Graql.parseQuery("insert $x true isa property;"));
tx.query().insert(Graql.parseQuery("insert $x false isa property;"));
Stream<? extends Attribute> properties = tx.concepts().getAttributeType("property").getInstances().limit(10);
properties.forEach(e -> { // the 2nd iteration will fail because the original collection has been modified by the delete() from the 1st iteration
e.delete();
});
tx.commit();
}
}
Instead, the user should collect the concepts onto a separate list and iterate over them:
Trying to delete concepts as you iterate over them will fail with a
ConcurrentModificationException
:Instead, the user should collect the concepts onto a separate list and iterate over them:
The text was updated successfully, but these errors were encountered: