Do not reuse global Context for cleanup actions...it may already be closed

This commit is contained in:
Tim Donohue
2020-02-05 16:19:41 -06:00
parent 7f879a2086
commit 73f8dc100e

View File

@@ -37,12 +37,15 @@ public class RelationshipTypeBuilder extends AbstractBuilder<RelationshipType, R
@Override @Override
public void cleanup() throws Exception { public void cleanup() throws Exception {
context.turnOffAuthorisationSystem(); try (Context c = new Context()) {
List<Relationship> byRelationshipType = relationshipService.findByRelationshipType(context, relationshipType); c.turnOffAuthorisationSystem();
for (Relationship relationship : byRelationshipType) { List<Relationship> byRelationshipType = relationshipService
relationshipService.delete(context, relationship); .findByRelationshipType(c, relationshipType);
for (Relationship relationship : byRelationshipType) {
relationshipService.delete(c, relationship);
}
c.complete();
} }
context.restoreAuthSystemState();
delete(relationshipType); delete(relationshipType);
} }