Problem with custom Plugin Settings

Hi !  does somebody know if there is any important change on the way jIDEA (PhpStorm) manages the plugin settings?
Some users are experimenting a NullPointerException on lines like this (this happens when they try to edit the plugin Settings inside File > Settings):

MySettings magicentoSettings = MySettings.getInstance(project);

The problem I guess is that ::getInstance(project) is returning null, maybe because project is null I don't know, I don't have too much information about this because I can't reproduce it, and is not happening to all the users, but I know some of them are experimenting this.

That line is from this class:

public class MySettings implements PersistentStateComponent<MySettings> {

  protected Project project;


  public static MySettin
gs getInstance(Project project)
        MySettings settings = ServiceManager.getService(project, MySettings.class);
        if(settings == null){             IdeHelper.logError("Cannot find Plugin Settings");         }         settings.project = project;   return settings;    ...

The previous code was working fine since years, I didn't change anything related with that, but suddenly some users are experimenting that error when trying to modify the plugin settings, so I guess there was a change in the code from jetbrains that could be affecting this, does somebody has any clue about this?

The error happens sometimes with this line too (on the same context: trying to edit the plugin setings)

return project.getComponent(MyProjectComponent.class);          // this is returning null

I was thinking that project could be "null" in that context for some reason, but I think is not the case, because the previous code is actually executed by this line:

public boolean hasMagentoPathInCurrentProject()
   String projectBasePath = MyProjectComponent.getInstance(project).getProjectPath();

And the NullPointerException trace is complanining about that line, that is, the ::getInstance not the ::getComponent

Example os the Stack Trace:

     at com.myplugin.MySettings.hasPathInCurrentProject(
     at com.myplugin.MySettings.getInstance(
     at com.myplugin.ui.forms.MySettingsForm.createComponent(
     at com.intellij.openapi.options.newEditor.OptionsEditor$Simple.<init>(
     at com.intellij.openapi.options.newEditor.OptionsEditor.c(
     at com.intellij.openapi.options.newEditor.OptionsEditor.access$1900(
     at com.intellij.openapi.options.newEditor.OptionsEditor$9$1$
     at com.intellij.openapi.application.impl.ApplicationImpl.runEdtSafeAction(
     at com.intellij.openapi.options.newEditor.OptionsEditor$9$
     at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(
     at com.intellij.openapi.options.newEditor.OptionsEditor$
     at com.intellij.openapi.application.impl.ApplicationImpl$
     at java.util.concurrent.Executors$
     at java.util.concurrent.FutureTask$Sync.innerRun(
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
     at java.util.concurrent.ThreadPoolExecutor$
     at org.jetbrains.ide.PooledThreadExecutor$1$

Maybe is related with some changes in the PhpStorm Settings, I remember that we had the settings separated by "Project Settings" and "Ide Settings" before, but now that separation doesn't exist.
The strange here is that this is working for almost everybody, using 8.0.2 and 8.0.3, so I'm not sure where to search the problem.

Comment actions Permalink

How is MySettings registered?

Comment actions Permalink


<projectService serviceImplementation="com.myplugin.MySettings"/>

And inside the class:

        name = "MySettings",    // must be equal to the class name I think
        storages = {
                @Storage(id = "default", file = "$PROJECT_FILE$"),
                @Storage(id = "dir", file = "$PROJECT_CONFIG_DIR$/myplugin.xml", scheme = StorageScheme.DIRECTORY_BASED)

But again, this was working for years and I've never changed that, and now some users are experimenting that bug, so I guess it must be related with some change in jIDEA or something like that, am I wrong?

Comment actions Permalink

Are there perhaps any exceptions happening before that one? I don't quite see what change could have caused this particular exception.

P.S. the name of the product is either "IntelliJ IDEA" or "IntelliJ' or "IDEA" but definitely not "jIDEA"


Please sign in to leave a comment.