Skip to content

Commit 001d501

Browse files
java-team-github-botGoogle Java Core Libraries
authored andcommitted
Fix J2ObjC retain-cycle in LinkedListMultimap:
``` (192 bytes) ROOT CYCLE: <ComGoogleCommonCollectLinkedListMultimap_Node 0x600001a075c0> [64] (64 bytes) next_ --> ROOT CYCLE: <ComGoogleCommonCollectLinkedListMultimap_Node 0x600001a07600> [64] previous_ --> CYCLE BACK TO <ComGoogleCommonCollectLinkedListMultimap_Node 0x600001a075c0> [64] ``` RELNOTES=n/a PiperOrigin-RevId: 759770348
1 parent 294c251 commit 001d501

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

android/guava/src/com/google/common/collect/LinkedListMultimap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.common.annotations.GwtIncompatible;
2626
import com.google.common.annotations.J2ktIncompatible;
2727
import com.google.errorprone.annotations.CanIgnoreReturnValue;
28+
import com.google.j2objc.annotations.Weak;
2829
import com.google.j2objc.annotations.WeakOuter;
2930
import java.io.IOException;
3031
import java.io.ObjectInputStream;
@@ -109,9 +110,9 @@ static final class Node<K extends @Nullable Object, V extends @Nullable Object>
109110
@ParametricNullness final K key;
110111
@ParametricNullness V value;
111112
@Nullable Node<K, V> next; // the next node (with any key)
112-
@Nullable Node<K, V> previous; // the previous node (with any key)
113+
@Weak @Nullable Node<K, V> previous; // the previous node (with any key)
113114
@Nullable Node<K, V> nextSibling; // the next node with the same key
114-
@Nullable Node<K, V> previousSibling; // the previous node with the same key
115+
@Weak @Nullable Node<K, V> previousSibling; // the previous node with the same key
115116

116117
Node(@ParametricNullness K key, @ParametricNullness V value) {
117118
this.key = key;

guava/src/com/google/common/collect/LinkedListMultimap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.common.annotations.GwtIncompatible;
2727
import com.google.common.annotations.J2ktIncompatible;
2828
import com.google.errorprone.annotations.CanIgnoreReturnValue;
29+
import com.google.j2objc.annotations.Weak;
2930
import com.google.j2objc.annotations.WeakOuter;
3031
import java.io.IOException;
3132
import java.io.ObjectInputStream;
@@ -112,9 +113,9 @@ static final class Node<K extends @Nullable Object, V extends @Nullable Object>
112113
@ParametricNullness final K key;
113114
@ParametricNullness V value;
114115
@Nullable Node<K, V> next; // the next node (with any key)
115-
@Nullable Node<K, V> previous; // the previous node (with any key)
116+
@Weak @Nullable Node<K, V> previous; // the previous node (with any key)
116117
@Nullable Node<K, V> nextSibling; // the next node with the same key
117-
@Nullable Node<K, V> previousSibling; // the previous node with the same key
118+
@Weak @Nullable Node<K, V> previousSibling; // the previous node with the same key
118119

119120
Node(@ParametricNullness K key, @ParametricNullness V value) {
120121
this.key = key;

0 commit comments

Comments
 (0)