diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/transaction/addedrelations/ConcurrentAddedRelations.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/transaction/addedrelations/ConcurrentAddedRelations.java index 78a8ef75440..97c696d5cfb 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/transaction/addedrelations/ConcurrentAddedRelations.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/transaction/addedrelations/ConcurrentAddedRelations.java @@ -15,9 +15,13 @@ package org.janusgraph.graphdb.transaction.addedrelations; import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import org.janusgraph.graphdb.internal.InternalRelation; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; /** * @author Matthias Broecheler (me@matthiasb.com) @@ -37,11 +41,18 @@ public synchronized boolean remove(final InternalRelation relation) { @Override public synchronized Iterable getView(final Predicate filter) { - return super.getView(filter); + return copyView(super.getView(filter)); } @Override public synchronized Collection getAll() { - return super.getAll(); + return new ArrayList<>(super.getAll()); } + + private Iterable copyView(Iterable currentView) { + ArrayList view = new ArrayList<>(); + Iterables.addAll(view, currentView); + return view; + } + }