diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart index 698f63fe084..049037742b9 100644 --- a/pkg/analysis_server/lib/src/server/driver.dart +++ b/pkg/analysis_server/lib/src/server/driver.dart @@ -428,11 +428,11 @@ class Driver implements ServerStarter { } _captureExceptions(service, () { - stdioServer.serveStdio().then((_) { + stdioServer.serveStdio().then((_) async { if (serve_http) { httpServer.close(); } - service.shutdown(); + await service.shutdown(); exit(0); }); }, diff --git a/pkg/analyzer/lib/instrumentation/file_instrumentation.dart b/pkg/analyzer/lib/instrumentation/file_instrumentation.dart index ba23b68f3b5..72691156d66 100644 --- a/pkg/analyzer/lib/instrumentation/file_instrumentation.dart +++ b/pkg/analyzer/lib/instrumentation/file_instrumentation.dart @@ -4,6 +4,7 @@ library file_instrumentation; +import 'dart:async'; import 'dart:io'; import 'package:analyzer/instrumentation/instrumentation.dart'; @@ -30,8 +31,8 @@ class FileInstrumentationServer implements InstrumentationServer { } @override - void shutdown() { - _sink.close(); + Future shutdown() async { + await _sink.close(); _sink = null; } } diff --git a/pkg/analyzer/lib/instrumentation/instrumentation.dart b/pkg/analyzer/lib/instrumentation/instrumentation.dart index 18772dead39..8b36303152f 100644 --- a/pkg/analyzer/lib/instrumentation/instrumentation.dart +++ b/pkg/analyzer/lib/instrumentation/instrumentation.dart @@ -4,6 +4,7 @@ library instrumentation; +import 'dart:async'; import 'dart:convert'; import 'package:analyzer/task/model.dart'; @@ -43,7 +44,7 @@ abstract class InstrumentationServer { * server. This method should be invoked exactly one time and no other methods * should be invoked on this instance after this method has been invoked. */ - void shutdown(); + Future shutdown(); } /** @@ -83,7 +84,7 @@ class InstrumentationService { int _subprocessCounter = 0; /** - * Initialize a newly created instrumentation service to comunicate with the + * Initialize a newly created instrumentation service to communicate with the * given [instrumentationServer]. */ InstrumentationService(this._instrumentationServer); @@ -216,7 +217,7 @@ class InstrumentationService { /** * Log the result of executing a subprocess. [subprocessId] should be the - * unique IDreturned by [logSubprocessStart]. + * unique ID returned by [logSubprocessStart]. */ void logSubprocessResult( int subprocessId, int exitCode, String stdout, String stderr) { @@ -290,9 +291,9 @@ class InstrumentationService { * server. This method should be invoked exactly one time and no other methods * should be invoked on this instance after this method has been invoked. */ - void shutdown() { + Future shutdown() async { if (_instrumentationServer != null) { - _instrumentationServer.shutdown(); + await _instrumentationServer.shutdown(); _instrumentationServer = null; } } @@ -373,9 +374,9 @@ class MulticastInstrumentationServer implements InstrumentationServer { } @override - void shutdown() { + Future shutdown() async { for (InstrumentationServer server in _servers) { - server.shutdown(); + await server.shutdown(); } } } diff --git a/pkg/analyzer/test/instrumentation/instrumentation_test.dart b/pkg/analyzer/test/instrumentation/instrumentation_test.dart index 290b71a296f..ac8755e3cd6 100644 --- a/pkg/analyzer/test/instrumentation/instrumentation_test.dart +++ b/pkg/analyzer/test/instrumentation/instrumentation_test.dart @@ -4,6 +4,8 @@ library test.instrumentation; +import 'dart:async'; + import 'package:analyzer/instrumentation/instrumentation.dart'; import 'package:unittest/unittest.dart'; @@ -174,7 +176,7 @@ class TestInstrumentationServer implements InstrumentationServer { } @override - void shutdown() { + Future shutdown() async { // Ignored } }