Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ public void addCloseListener(ActionListener<Void> listener) {
// if the channel is already closed, the listener gets notified immediately, from the same thread.
if (open.get() == false) {
listener.onResponse(null);
// Ensure closeLatch is pulled by completing the closeListener with a noop that is ignored if it is already completed.
// Note that when the channel is closed we may see multiple addCloseListener() calls, so we do not assert on isDone() here,
// and since closeListener may already be completed we cannot rely on it to complete the current listener, so we first
// complete it directly and then pass a noop to closeListener.
closeListener.onResponse(ActionListener.assertOnce(ActionListener.noop()));
} else {
assertFalse("close listener already set, only one is allowed!", closeListener.isDone());
closeListener.onResponse(ActionListener.assertOnce(listener));
Expand Down