This caused on assertion failure on failure to connect.
The problem here was that we did
Future.sequence(done,closed).onComplete(closeHandler),
but if any future in the sequence fails we immediately complete
the whole sequence, so the closeHandler would run on failure
to connect.
Changing onComplete to onSuccess would probably be enough to
fix this but I rewrote the code to be more explicit.
The explicit code should more clearly do the right thing without
relying on many guarantees about how Future works.
This caused on assertion failure on failure to connect.
The problem here was that we did Future.sequence(done,closed).onComplete(closeHandler), but if any future in the sequence fails we immediately complete the whole sequence, so the closeHandler would run on failure to connect.
Changing onComplete to onSuccess would probably be enough to fix this but I rewrote the code to be more explicit. The explicit code should more clearly do the right thing without relying on many guarantees about how Future works.