Fix race condition in protocol_discovery.dart (#10092)

For some reaosn, when we discovered our URI, we were re-instantiating
the `Completer` instance variable whose future we listen to in `nextUri()`.
This led to a race between a caller calling `nextUri()` and us discovering
the URI. If we happened to discover our URI before a caller called
`nextUri()`, then they would be left waiting on a future from the newly
allocated `Completer` (which would never complete).

Fixes #10064
This commit is contained in:
Todd Volkert
2017-05-16 08:25:51 -07:00
committed by GitHub
parent ce2c834f70
commit 10decc7c19
5 changed files with 154 additions and 111 deletions

View File

@@ -407,12 +407,12 @@ class AndroidDevice extends Device {
if (debuggingOptions.buildMode == BuildMode.debug) {
final List<Uri> deviceUris = await Future.wait(
<Future<Uri>>[observatoryDiscovery.nextUri(), diagnosticDiscovery.nextUri()]
<Future<Uri>>[observatoryDiscovery.uri, diagnosticDiscovery.uri]
);
observatoryUri = deviceUris[0];
diagnosticUri = deviceUris[1];
} else if (debuggingOptions.buildMode == BuildMode.profile) {
observatoryUri = await observatoryDiscovery.nextUri();
observatoryUri = await observatoryDiscovery.uri;
}
return new LaunchResult.succeeded(