Error when downloading and Installing the plugin during multiple instance of Intellij IDE is running.

Answered

Hi 

We have created private marketplace plugin that connect to private Artifactory of the org and get the  organization specific plugin and loads the plugin when the IntelliJ IDE is opened. One of the feature is when the IDE is opened the latest version of the plugin is download form the Artifactory if new version is available.

We are getting below error/  exception when multiple instance of IDE Is opened at the sometime and each instance of IDE  is trying to download and install the latest version of the plugin at the sometime. 

We are looking into some approaches 

1. To Execute a one time process when a plugin is initially loaded - we want this to happen for one instance of the IDE only, i.e., if multiple instances of the IDE are opened, then the process should only execute once. Currently, when we run startup activity for a plugin, it runs once per instance of the IDE. Is there a thread that is run at the IDE global level rather than per instance that we could take advantage of? If not, what alternatives might we look at?`

2. Trigger an action when an IDE is brought into focus - i.e., if you have multiple instances of the IDE opened simultaneously, when we click on a particular instance is there a way to detect this focus event at the IDE instance level.

Error -

java.lang.Throwable: Assertion failed at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:218)

at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:227)

at com.intellij.ide.plugins.PluginSet.enablePlugin(PluginSet.kt:112)

at com.intellij.ide.plugins.DynamicPlugins.loadPlugin(DynamicPlugins.kt:803)

at com.intellij.ide.plugins.DynamicPlugins.loadPlugin(DynamicPlugins.kt:790)

at com.intellij.ide.plugins.PluginInstaller.installAndLoadDynamicPlugin(PluginInstaller.java:392)

 

 

3 comments
Comment actions Permalink

1. Please clarify :

"multiple instance of IDE Is opened at the sometime and each instance of IDE is trying to download and install the latest version of the plugin"

- what is "multiple instance of IDE"? multiple open projects? separate instances of IDE? if yes, do they share same configuration directory accidentally?

- what is "IDE is trying to download"? automatic check for Updates for plugins? manual invocation of updates check? some code in your plugin triggering this?

 

AFAIU your plugin fails because of some automatic activity triggered immediately after update/installation.

To trigger activity exactly once per application or per project, see approaches listed here https://plugins.jetbrains.com/docs/intellij/plugin-components.html#application-startup

 

2. Use topic com.intellij.openapi.application.ApplicationActivationListener, see https://plugins.jetbrains.com/docs/intellij/plugin-listeners.html on how register

0
Comment actions Permalink

Hi - We mean Multiple projects opened in IntelliJ IDEA. Plz find the screenshot.

We wanted startup activity triggered for only one project if multiple projects are opened.

0
Comment actions Permalink

It seems you could use your own static Atomic Counter/Lock field to prevent this. Or switch to application startup solution mentioned previously.

0

Please sign in to leave a comment.