Skip to content

[BUG] The ServerPlugin.stop() function could be called multiple times when the server shuts down. #120

Closed

Description

@sbraconnier-op3c

Describe the bug
Not sure how to explain this one. I'm working on a plugin for OIE and I was struggling with some errors appearing on the mirth.log file on server shutdown.

If you look at the initPlugins function, you can see that each plugin will be put in a specific map according to their plugin type (here, here, here, etc.), but they are also added to an ArrayList of server plugins.

Now if you look at the stopPlugins function that is called when the server shuts down, you'll see that the stop function is called for each plugin in the array list, thus, multiple times if you have a class that implements multiple ServerPlugin.

To Reproduce
Create a plugin that implements multiple "ServerPlugin" interface. Let's say I have a class that implements the ServicePlugin interface that also implements the ChannelPlugin (cuz the service needs to intercept channel creation, save, deletion, etc.). Then the "stop()" function will be called twice.

Expected behavior
The "stop" function should be called only once.

Actual behavior
The "stop" function is called according to the number of "ServerPlugin" interfaces the class implements.

Workaround(s)
Create a dedicated class for each type of ServerPlugin you want to implement. Then if you have something to do that can only be done once, do it in the proper class implementation.

Additional context
I would be happy to work on this one if the community thinks it would nice to solve this.

Activity

  1. jonbartels commented on Jul 30, 2026

    @jonbartels
    Contributor

    Not sure how to explain this one. I'm working on a plugin for OIE and I was struggling with some errors appearing on the mirth.log file on server shutdown.

    What errors did you see on server shutdown?

    Can you also show a snippet of what your plugins stop implementation looks like? a solution may be to make either your plugin, or OIE, tolerate calling stop() more than once.

  2. sbraconnier-op3c commented on Jul 30, 2026

    @sbraconnier-op3c
    Author

    This is what I did.

    And my case was about closing a connection pool.

    But it feels odd and probably not the intended behavior. This isn't a big problem. But when you develop a plugin, you don't expect to have to manage your "stop" function to be called multiple time by the framework.

    Could be resolved by documenting this behavior. DO NOT implement more than 1 server plugin interface in the same class.

    Manageable, but not ideal...

  3. changed the title [-][BUG] The ServerPlugin.close() function could be called multiple times when the server shuts down.[/-] [+][BUG] The ServerPlugin.stop() function could be called multiple times when the server shuts down.[/+] on Jul 30, 2026
  4. added a commit that references this issue on Jul 31, 2026
    aac9558
  5. added this to the Next Release milestone on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions