Fix UnsignedLongSet entry lifecycle
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / utils / UnsignedLongSet.java
index 14e3b6a41fce6e681b95c38ebe945fdbf5a6388f..e3fa6263e634a99078de115f7ba51314b76ebb60 100644 (file)
@@ -19,6 +19,7 @@ import com.google.common.primitives.UnsignedLong;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.NavigableSet;
 import java.util.TreeSet;
@@ -151,7 +152,7 @@ abstract class UnsignedLongSet {
     public abstract @NonNull ImmutableUnsignedLongSet immutableCopy();
 
     public final @NonNull MutableUnsignedLongSet mutableCopy() {
-        return new MutableUnsignedLongSet(new TreeSet<>(Collections2.transform(ranges, Entry::copy)));
+        return new MutableUnsignedLongSet(new TreeSet<>(copiedRanges()));
     }
 
     public final @NonNull NavigableSet<Entry> ranges() {
@@ -162,6 +163,10 @@ abstract class UnsignedLongSet {
         return ranges;
     }
 
+    final @NonNull Collection<Entry> copiedRanges() {
+        return Collections2.transform(ranges, Entry::copy);
+    }
+
     @Override
     public final int hashCode() {
         return ranges.hashCode();