Skip to content

Commit 533ec6c

Browse files
Add comment details per review
1 parent 114be1f commit 533ec6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/test/java/org/elasticsearch/rest/action/RestCancellableNodeClientTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ public void addCloseListener(ActionListener<Void> listener) {
304304
if (open.get() == false) {
305305
listener.onResponse(null);
306306
// Ensure closeLatch is pulled by completing the closeListener with a noop that is ignored if it is already completed.
307-
// Note that when the channel is closed we may see multiple addCloseListener() calls, so we do not assert on isDone() here.
307+
// Note that when the channel is closed we may see multiple addCloseListener() calls, so we do not assert on isDone() here,
308+
// and since closeListener may already be completed we cannot rely on it to complete the current listener, so we first
309+
// complete it directly and then pass a noop to closeListener.
308310
closeListener.onResponse(ActionListener.assertOnce(ActionListener.noop()));
309311
} else {
310312
assertFalse("close listener already set, only one is allowed!", closeListener.isDone());

0 commit comments

Comments
 (0)