Return value of IResourceRuleFactory.modifyRule() not consistent? [message #1066778] |
Thu, 04 July 2013 10:39 |
Rüdiger Herrmann Messages: 581 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
|
|
|
Powered by
FUDForum. Page generated in 0.02535 seconds