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:

null
java.lang.NullPointerException
     at com.myplugin.MySettings.hasPathInCurrentProject(MySettings.java:507)
     at com.myplugin.MySettings.getInstance(MySettings.java:105)
     at com.myplugin.ui.forms.MySettingsForm.createComponent(MySettingsForm.java:413)
     at com.intellij.openapi.options.newEditor.OptionsEditor$Simple.<init>(OptionsEditor.java:1052)
     at com.intellij.openapi.options.newEditor.OptionsEditor.c(OptionsEditor.java:507)
     at com.intellij.openapi.options.newEditor.OptionsEditor.access$1900(OptionsEditor.java:67)
     at com.intellij.openapi.options.newEditor.OptionsEditor$9$1$1.run(OptionsEditor.java:476)
     at com.intellij.openapi.application.impl.ApplicationImpl.runEdtSafeAction(ApplicationImpl.java:1093)
     at com.intellij.openapi.options.newEditor.OptionsEditor$9$1.run(OptionsEditor.java:469)
     at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:908)
     at com.intellij.openapi.options.newEditor.OptionsEditor$9.run(OptionsEditor.java:466)
     at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:406)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
     at java.lang.Thread.run(Thread.java:695)
     at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)



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.

3 comments
Comment actions Permalink

How is MySettings registered?


0
Comment actions Permalink

plugin.xml

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


And inside the class:

@State(
        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?

0
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"

0

Please sign in to leave a comment.