Ensure shutdown and terminate always return a Future<Null>. (#75)

Even if _transport.finish()/terminate() returns some other kind of
Future.
This commit is contained in:
Jakob Andersen 2018-03-28 14:54:09 +02:00 committed by GitHub
parent c914f67c11
commit 0393703f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -184,19 +184,19 @@ class ClientConnection {
/// ///
/// No further calls may be made on this connection, but existing calls /// No further calls may be made on this connection, but existing calls
/// are allowed to finish. /// are allowed to finish.
Future<Null> shutdown() { Future<Null> shutdown() async {
if (_state == ConnectionState.shutdown) return new Future.value(); if (_state == ConnectionState.shutdown) return null;
_setShutdownState(); _setShutdownState();
return _transport?.finish() ?? new Future.value(); await _transport?.finish();
} }
/// Terminates this connection. /// Terminates this connection.
/// ///
/// All open calls are terminated immediately, and no further calls may be /// All open calls are terminated immediately, and no further calls may be
/// made on this connection. /// made on this connection.
Future<Null> terminate() { Future<Null> terminate() async {
_setShutdownState(); _setShutdownState();
return _transport?.terminate() ?? new Future.value(); await _transport?.terminate();
} }
void _setShutdownState() { void _setShutdownState() {