Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Return value of IResourceRuleFactory.modifyRule() not consistent?
Return value of IResourceRuleFactory.modifyRule() not consistent? [message #1066778] Thu, 04 July 2013 10:39
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 563
Registered: July 2009
Senior Member
Hi all,

I am trying to track down a strange behavior of resource rules. Viewed
from outside, Job.getJobManager().beginRule() sometimes throws an
IllegalArgumentException: Attempted to beginRule: R/, does not match
outer scope rule: P/my-project

The exception occurs in a large PDE JUnit test suite that creates many
projects, an IResourceChangeListener that is registered in most cases
observes and schedules a job like this one for each new project:

class MyJob extends Job {
final IProject project;
MyJob( IProject project ) {
super( "my job" );
this.project = project;
IWorkspace ws = project.getWorkspace();
ISchedulingRule rule = ws.getRuleFactory().modifyRule( project );
setRule( rule );
}

protected IStatus run( IProgressMonitor monitor ) {
IWorkspace ws = project.getWorkspace();
ISchedulingRule rule = ws.getRuleFactory().modifyRule( project );
try {
Job.getJobManager().beginRule( rule, null );
// do something with project ...
} finally {
Job.getJobManager().endRule( rule );
}
return Status.OK_STATUS;
}
}

It seems as if the rule obtained in run() sometimes is the workspace
root whereas the rule obtained in the constructor is always the project.
I would expect both calls to always return the same rule.

When trying to isolate the issue like below everything works as expected.
@Test
public void testMyJob() throws Exception {
for( int i = 0; i < 200; i++ ) {
IProject project = // create new project
MyJob job = new MyJob( project );
job.schedule();
}
Job.getJobManager().join( MyJob.class, null )
}

Can anyone shed some light into this or give me a pointer what else to
investigate.

TIA
Rüdiger
Previous Topic:Eclipse encoding on MACOSX
Next Topic:Customize the eclipse LogView
Goto Forum:
  


Current Time: Tue Sep 16 17:39:34 GMT 2014

Powered by FUDForum. Page generated in 0.01575 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software