Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316182 - Calling RepositoryProvider.getProvider(IProject pjct) throws null pointer exception.
Summary: Calling RepositoryProvider.getProvider(IProject pjct) throws null pointer exc...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.8 M6   Edit
Assignee: Szymon Ptaszkiewicz CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-08 13:50 EDT by John P. Petrakis CLA
Modified: 2012-03-07 05:49 EST (History)
6 users (show)

See Also:
Szymon.Brandys: review+


Attachments
Patch (7.28 KB, patch)
2012-03-05 09:02 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John P. Petrakis CLA 2010-06-08 13:50:57 EDT
Build Identifier: M20090917-0800

I'm calling getProvider in the early stages of eclipse startup and while I don't necessarily expect it to return anything but null, what I get is an NPE when the call is made.  In particular the traceback shows it is trying to exec this line:

org.eclipse.core.internal.resources.Resource.getPersistentProperty(Resource.java:1067)  Which is here:

	public String getPersistentProperty(QualifiedName key) throws CoreException {
		checkAccessibleAndLocal(DEPTH_ZERO);
		return getPropertyManager().getProperty(this, key);
	}

And it turns out that getProperyManager is returning as null...  This is being called in a RefreshProvider context so it is running from refreshprovider's installMonitor method at startup.

The doc does appear to state that getPers.Prop could throw a CoreException or return null.

It happens every time in the sense that if I make this call when 1) refresh workspace is enabled, and I've just started the workbench and then do the provider check (which of course forces installMonitor to be called during the early phases of the startup... but the project is open and available.

Reproducible: Always

Steps to Reproduce:
1. create a refresh provider plugin
2. in installMonitor add RepositoryProvider.getProvider((IProject)resource); // or whatever you need to get a project root
3. add some project to your workspace
4. turn on refresh.
5. restart workbench. ---> that's when I get the npe on the call.
Comment 1 John P. Petrakis CLA 2010-06-08 13:54:17 EDT
I realize that it's possible that full initialization hasn't occured, but in our case, it would be exceedingly helpful to be able to make this call for a repo provider at the time installMonitor is being called.  The fact that installMonitor is called so early and in the main thread does have some important performance implications which I'm trying to resolve.
Comment 2 Tomasz Zarna CLA 2010-06-10 07:02:50 EDT
This sounds more like a Resources issue, moving to their inbox for comment.
Comment 3 Szymon Brandys CLA 2010-06-14 09:43:46 EDT
It can be easily reproduced with the steps from comment 0.

A refresh provider with #installMonitor as below

public IRefreshMonitor installMonitor(IResource resource, IRefreshResult result){
  try {
    resource.getProject().getPersistentProperty(new QualifiedName("q", "n"));
  } catch (CoreException e) {
    e.printStackTrace();
  }		
  return null;
}

will throw NPE on workbench restart when auto-refresh is enabled.
Comment 4 James Blackburn CLA 2010-11-05 05:51:31 EDT
This looks pretty straightforward to fix -- just move the propertymanager higher in the Workspace#startup.
Comment 5 John Arthorne CLA 2010-11-05 11:23:59 EDT
Well, I think the deeper problem is that the refresh provider is being initialized too early in startup while the resource plugin is still in the middle of activation.
Comment 6 Szymon Ptaszkiewicz CLA 2012-03-05 09:02:19 EST
Created attachment 212066 [details]
Patch

https://git.eclipse.org/r/#/c/5244/
Comment 7 Szymon Ptaszkiewicz CLA 2012-03-05 09:03:46 EST
Szymon, please review.