| Summary: | Ex;tensionPointEnabler getPluginModelForProject throws NPE | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Stan Sutton <suttons> |
| Component: | IMP | Assignee: | Robert M. Fuhrer <rfuhrer> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | jurgen.vinju, pcharles, rfuhrer, suttons |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Stan Sutton
The method contained a loop, in which the workspace models were iteratively
checked for one (presumably a project plugin model) with an ID that matched the
name of the given project:
private static IPluginModel getPluginModelForProject(final IProject project) {
PluginModelManager pmm = PDECore.getDefault().getModelManager();
IPluginModelBase[] wsPlugins= pmm.getWorkspaceModels();
if (wsPlugins.length == 0) { ... return null; }
for(int i= 0; i < wsPlugins.length; i++) {
IPluginModelBase wsPlugin= wsPlugins[i];
if (wsPlugin.getPluginBase().getId().equals(project.getName())) {
return (IPluginModel) wsPlugin;
}
}
ErrorHandler.reportError("Could not find plugin for project " +
project.getName(), true);
return null;
}
It seems that the set of workspace models also includes a workspace plugin
model, which (at least in the case of my runtime workbench) has a null ID. That
lead to the NPE. Since the workspace model happened to be the second model
checked, that meant that most project plugin models could not be found.
I had not seen this problem before, and I'm not sure whether it would arise only
in a runtime workbench, whether it relates to some other change that has been
made, or whether it's simply a matter of chance.
The solution that I've implemented is to check for nulls in the various elements
that go into the test against the project name and to continue the iteration if
any of them is null. Regardless of why the problem has turned up now, this
seems to be a reasonable thing to do.
This is perhaps the nastiest of bugs in the SAFARI "front end", and *seems* to be due to some strange and somewhat intermittent caching done by the PDE. By the time the code in question is reached (if my memory serves me), it should already have been established that the project is a plugin project, and moreover is open, so I believe it's safe to assume that the PDE should have or be able to create a "workspace plugin model" (or thereabouts). Obviously, either there's a bug in the PDE (which is my guess), or the PDE was never intended to provide this guarantee (which would be somewhat shocking, or at least counter-intuitive). <gratuitous comment for change of status> |