diff --git a/core/src/main/java/overflowdb/ReferenceManager.java b/core/src/main/java/overflowdb/ReferenceManager.java index bacb11fe..1bfed5ae 100644 --- a/core/src/main/java/overflowdb/ReferenceManager.java +++ b/core/src/main/java/overflowdb/ReferenceManager.java @@ -152,8 +152,10 @@ private void safelyClearReferences(final List refsToClear) { * useful when saving the graph */ public void clearAllReferences() { - nodesWriter.writeAndClearBatched(clearableRefs.spliterator(), clearableRefs.size()); - logger.debug("cleared all clearable references"); + synchronized (clearableRefs){ + nodesWriter.writeAndClearBatched(clearableRefs.spliterator(), clearableRefs.size()); + logger.debug("cleared all clearable references"); + } } @Override