diff --git a/server/src/main/java/com/mirth/connect/server/controllers/DefaultExtensionController.java b/server/src/main/java/com/mirth/connect/server/controllers/DefaultExtensionController.java index e3a076c91e..77b02c1874 100644 --- a/server/src/main/java/com/mirth/connect/server/controllers/DefaultExtensionController.java +++ b/server/src/main/java/com/mirth/connect/server/controllers/DefaultExtensionController.java @@ -84,7 +84,14 @@ public class DefaultExtensionController extends ExtensionController { // these are plugins for specific extension points, keyed by plugin name // (not path) - private List serverPlugins = new ArrayList(); + /* + * A plugin class may implement several of the plugin type interfaces, in which case it is + * registered once for each interface it implements. A Set holds a single entry per plugin, + * so start() and stop() are invoked once per plugin rather than once per interface. + * LinkedHashSet because initPlugins loads plugins in a deliberate order (by plugin weight) + * and that order is preserved when they are started and stopped. + */ + private Set serverPlugins = new LinkedHashSet(); private Map servicePlugins = new LinkedHashMap(); private Map channelPlugins = new LinkedHashMap(); private Map codeTemplateServerPlugins = new LinkedHashMap(); @@ -716,7 +723,8 @@ public List getClientLibraries() { } public List getServerPlugins() { - return serverPlugins; + // Copied into a List so the ExtensionController signature stays unchanged for extensions. + return new ArrayList(serverPlugins); } void extractZipEntry(ZipEntry entry, File installTempDir, ZipFile zipFile) throws IOException {