Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in DefaultPluginManager.stopPlugin #99

Closed
xiyoufang opened this issue Apr 10, 2016 · 12 comments
Closed

NPE in DefaultPluginManager.stopPlugin #99

xiyoufang opened this issue Apr 10, 2016 · 12 comments

Comments

@xiyoufang
Copy link

If plugins directory is null, load and start a Plugin, finally stop plugin :
Exception in thread "main" java.lang.NullPointerException at ro.fortsoft.pf4j.DefaultPluginManager.stopPlugin(DefaultPluginManager.java:340) at ro.fortsoft.pf4j.DefaultPluginManager.stopPlugin(DefaultPluginManager.java:317)
If plugins directory is not null, not have this Exception.
pluginsDirectory is null , dependencyResolver can't instanced

@decebals
Copy link
Member

I will take a look. Pull Request is welcome.

@decebals
Copy link
Member

You are right, the value of dependencyResolver at line 340 in DefaultPluginManager.stopPlugin(pluginId) but I don't understand how it's possible to get to that line in this context.
If the plugins directory is null or empty if you call DefaultPluginManager.stopPlugin(pluginId) the first line sin this method are:

if (!plugins.containsKey(pluginId)) {
    throw new IllegalArgumentException(String.format("Unknown pluginId %s", pluginId));
}

So, I believe that something is strange in your code.
Can you give me more details about this issue?

@xiyoufang
Copy link
Author

  1. Call loadPlugins(). Because plugins Directory is empty, defaultPluginManager.java 392 line directories.length == 0 is true. dependencyResolver is null .
  2. Call loadPlugin(File pluginArchiveFile) and startPlugin(pluginId). plugins is not empty, dependencyResolver is null.
  3. Call stopPlugin(pluginId). plugins.containsKey(pluginId) is true, but dependencyResolver is null, in DefaultPluginManager.java 340 line throw NullPointerException.

@MsDakota13
Copy link

By adding a small check on dependencyResolver not being null or else skipping the line where it trigger the NPE fixed the issue for me. It happens for plugins without dependencies in most projects both with version 0.13 and the snapshot version of 0.14. Basically this confirms the finding xiyoufang mentioned in his/her comment. This bug even occurs by using the sample code only in the sample projects. I am not sure if you have this fixed yet. If it has been fixed ignore this post all together.

@decebals
Copy link
Member

@heyokajan Thanks for comment. I will check if the fix is already pushed on github and if it's not then I will push the fix.

@decebals
Copy link
Member

@xiyoufang, @heyokajan Please try the fix and confirm that the issue is resolved.

@justinnichols
Copy link

Is there a workaround for this until the next release?

@decebals
Copy link
Member

I don't have any feedback from people if this issue is resolved or not on trunk. I updated the SNAPSHOT version.
All I want to add for next version is a protection for #82 (extension not found) because is very time consuming for me to offer support for this kind of problem.
If this issue is a stopper for you and if the bug is resolved in trunk (please test yourself) I can release a new version that will contain this bug fix.

@justinnichols
Copy link

I will test based on the SNAPSHOT, thanks!

@justinnichols
Copy link

Confirmed, 0.14.0-SNAPSHOT fixes this issue for me.

@justinnichols
Copy link

I can stay on the snapshot for now, but definitely would love to go back to release once you feel 0.14.0 is ready.

@decebals
Copy link
Member

@justinnichols Thank you for confirmation

@decebals decebals changed the title stopPlugin NPE NPE in DefaultPluginManager.stopPlugin Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants