Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 1199083002: rework packageMapInfo dependency watching to avoid race condition (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 654bcbe134cfd6b37738e2db872db1d4570c7d5d..c397a80b9bd646f84f9fe7c1656cd1eefa81762c 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -438,15 +438,21 @@ abstract class ContextManager {
endComputePackageMap();
for (String dependencyPath in packageMapInfo.dependencies) {
Resource resource = resourceProvider.getResource(dependencyPath);
- if (resource is File && resource.exists) {
- info.dependencySubscriptions.add(resource.changes
- .listen((WatchEvent event) {
+ if (resource is File) {
+ StreamSubscription<WatchEvent> subscription;
+ subscription = resource.changes.listen((WatchEvent event) {
if (info.packageMapInfo != null &&
info.packageMapInfo.isChangedDependency(
dependencyPath, resourceProvider)) {
_recomputePackageUriResolver(info);
}
- }));
+ }, onError: (error, StackTrace stackTrace) {
+ // Gracefully degrade if file is or becomes unwatchable
+ _instrumentationService.logException(error, stackTrace);
+ subscription.cancel();
+ info.dependencySubscriptions.remove(subscription);
+ });
+ info.dependencySubscriptions.add(subscription);
}
}
info.packageMapInfo = packageMapInfo;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698