Skip to content

Commit

Permalink
Issue 90868. Fix race condition in PluginManager.addPluginToContextRoot
Browse files Browse the repository at this point in the history
1. We start stopping the plugin in removedContextRoot.
2. We add the plugin to the map in addPluginToContextRoot.
3. We receive the notification that the plugin stopped, and remove the
   plugin by its path from the map.

The issue is that the map has already been updated to contain the newly
started plugin, with the same path. As a result, we forget that we have
a plugin started, and never stop it.


Bug: flutter/flutter#90868
Change-Id: I46c294c555905f0e9f298044718b281cb890e8ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 28, 2021
1 parent fa428da commit 7ee2744
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/analysis_server/lib/src/plugin/plugin_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,10 @@ class PluginManager {
try {
var session = await plugin.start(byteStorePath, sdkPath);
session?.onDone.then((_) {
_pluginMap.remove(path);
_notifyPluginsChanged();
if (_pluginMap[path] == plugin) {
_pluginMap.remove(path);
_notifyPluginsChanged();
}
});
} catch (exception, stackTrace) {
// Record the exception (for debugging purposes) and record the fact
Expand Down

0 comments on commit 7ee2744

Please sign in to comment.