Skip to content

CallFuture follow-up: Consumer error handlers, accurate comments - #108

Merged
FZambia merged 2 commits into
masterfrom
callfuture-followup
Nov 10, 2026
Merged

FZambia merged 2 commits into
masterfrom
callfuture-followup

Conversation

@FZambia

@FZambia FZambia commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #107.

  • Error handlers passed to Client.settle are now CallFuture.Consumer<Throwable> instead of Function<Throwable, Void>. This drops the return null; from 16 lambdas in Client and Subscription and removes the CallFuture.Function interface. No behaviour change.
  • CallFuture.whenComplete now rejects a second listener even after the future is done. The old check looked at the listener field, which is never set when a listener is registered after completion and is cleared on settle, so it worked only while the future was pending. New test: testSecondListenerRejected.
  • Fixes comments that Remove streamsupport-minifuture dependency #107 left inaccurate:
    • ConnectFailureHandlingTest: the timeout timer fires on the scheduler thread but hops to the executor before failing the future.
    • sendConnect: explains why the connect error handler still defers to a separate executor task. A failure from failPendingCalls() arrives in the middle of processDisconnect, which must finish before the handler reports the error and disconnects again.

./gradlew :centrifuge:test passes (110 tests).

…comments

Error handlers passed to Client.settle are now CallFuture.Consumer<Throwable>
instead of Function<Throwable, Void>, dropping the 'return null;' at every
call site and the Function interface.

Fix comments left over from #107: the connect timeout fails the future on
the executor (the scheduler timer hops there first), and the connect error
handler still defers to a separate executor task because a failure from
failPendingCalls() arrives in the middle of processDisconnect.
The guard checked the listener field, which is never set for a listener
registered after completion and is cleared on settle, so a second
listener was rejected only while the future was pending.
@IliaKazakov

Copy link
Copy Markdown
Contributor

@FZambia First of all, thanks for reviewing and merging my changes!

The follow-up looks good 👍
Nice catch on the second listener after completion, and thanks for fixing it. Feel free to merge and release.

@FZambia
FZambia merged commit 76b7da8 into master Nov 10, 2026
12 checks passed
@FZambia
FZambia deleted the callfuture-followup branch November 10, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants