Fix #120: start and stop each server plugin only once #397
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 443 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #397"
general
weight: 0.35
NicoPiel
Summary
Fixes #120. A plugin whose class implements several of the plugin type interfaces was registered once per interface, so it was started and stopped multiple times.
Root cause
DefaultExtensionController.initPlugins()checks each loaded plugin against every plugin type in turn, and each of the eight branches adds the instance to the sameserverPluginscollection:Because that collection was an
ArrayList, a class implementing bothServicePluginandChannelPluginends up in it twice.Note the issue title mentions
close(); the methods actually affected arestart()andstop()onServerPlugin.Impact beyond start/stop
The duplicate entries affect every consumer of that collection, not just shutdown:
startPlugins()/stopPlugins()invokestart()andstop()once per implemented interface instead of once per plugin. This is the shutdown noise reported in the issue.AlertWorkerbuilds itsalertActionAcceptorslist by iteratinggetServerPlugins()and filtering oninstanceof AlertActionAcceptor, so a duplicated plugin is added repeatedly and its alert actions run once per implemented interface.DefaultUsageControllerreports plugin usage from the same collection, so counts are inflated for multi-interface plugins.Fix
serverPluginsis now aSet, so a plugin registered for several interfaces is held once and the de-duplication is the natural behaviour of the collection. The eight registration calls are unchanged.LinkedHashSetrather thanHashSet:initPlugins()deliberately loads plugins in descending plugin weight order, and preserving that order means they are started and stopped in the intended sequence.getServerPlugins()still returnsList<ServerPlugin>, so theExtensionControllersignature is unchanged for extensions. It now returns a copy rather than the live internal collection.Net change is 10 insertions and 2 deletions in one file.
On testing
The earlier revision of this PR routed the registrations through a de-duplicating helper and unit tested it. Following review that has been dropped in favour of the
Set, and the tests went with it: they exercised the helper directly, and the invariant is now enforced by the collection type rather than by logic of our own.Testing this through
initPlugins()instead is not really reachable from a unit test, since it requires plugin metadata loading plus database access viasetPluginProperties. If you would like coverage here, I am happy to look at an integration-level test.Verified with
./gradlew :server:test(613 tests, 0 failures) and./gradlew :donkey:test.Note on the failing check
The
FileReceiverTest > testPoll1failure on the previous commit is unrelated to this change, which touches only plugin registration. The assertion atFileReceiverTest.java:133counts files picked up by a poll, and it passes locally both in the full suite and across three consecutive isolated runs. Given the recent "Allow parallel tests" change, this looks like a timing-sensitive flake rather than a real regression.How to verify
Build a plugin whose class implements two
ServerPluginsub-interfaces, for exampleServicePluginandChannelPlugin, and log a line instop(). Before this change the line appears twice on server shutdown; after it, once.