File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
core/src/main/java/dev/failsafe/internal/util Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,18 @@ public synchronized CompletableFuture<Void> pollFirst() {
6767 return previousHead == null ? null : previousHead .future ;
6868 }
6969
70+ /*
71+ * This looks dodgy: we are 'leaking' reference to the node object via future.whenComplete, so
72+ * this can end up being called for a node that has already been removed. This could have caused
73+ * problems. But in reality it currently would not because the only way to remove a node is via
74+ * pollFirst - i.e. by polling from the head of the list. This means that if node passed to this
75+ * function has already been removed it would imply that it's 'previous' field is always null
76+ * (it was in the head of the list before removal). And it's 'next' points to current head of
77+ * the list, so when we replace node.next.previous with node.previous we always replace null
78+ * with null. This whole assumption would break it this list allowed to add from the head of the
79+ * list, or remove from the tail or middle. So this is somewhat fragile, but currently seems to
80+ * be working fine.
81+ */
7082 private synchronized void remove (Node node ) {
7183 if (node .previous != null )
7284 node .previous .next = node .next ;
You can’t perform that action at this time.
0 commit comments