Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » On the use of Workspace and WorkManager API
On the use of Workspace and WorkManager API [message #1249883] Tue, 18 February 2014 18:39
El Arbi Aboussoror is currently offline El Arbi Aboussoror
Messages: 90
Registered: June 2010
Member
Hi,

I was facing some troubles with an eclipse based product, I had the following exception raising at product startup:
	org.eclipse.core.runtime.AssertionFailedException: assertion failed: Operation was not prepared.
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.internal.resources.Workspace.beginOperation(Workspace.java:297)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1971)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1957)
	at org.eclipse.jdt.internal.core.JavaModelManager$19.run(JavaModelManager.java:4733)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Sometimes it raises from the JavaModelManager.run and sometimes from another job (e.g. AutoBuildJob). The problem was our misuse of the WorkManager checkin/checkout, beginUnprotected/endUnprotected methods. It took me a while to understand that I should rather use workspace.prepareOperation / beginOperation instead of a checkin.
This misuse led to an Assert.isTrue(false) in the org.eclipse.core.internal.resources.Workspace.beginOperation(boolean) method:

	public void beginOperation(boolean createNewTree) throws CoreException {
		WorkManager workManager = getWorkManager();
		workManager.incrementNestedOperations();
		if (!workManager.isBalanced())
			Assert.isTrue(false, "Operation was not prepared.");
		if (workManager.getPreparedOperationDepth() > 1) {
			if (createNewTree && tree.isImmutable())
				newWorkingTree();
			return;
		}
....




The WorkManager documentation says Quote:
" ...This class also tracks operation state for each thread that is involved in an operation. This includes prepared and running operation depth, auto-build strategy and cancel state."


But I still don't understand completely what is the semantics behind the WorkManager fields:
org.eclipse.core.internal.resources.WorkManager.preparedOperations
and org.eclipse.core.internal.resources.WorkManager.nestedOperations ?

And what is the meaning of an unbalanced WorkManger (workManager.isBalanced() == false) ?


[Updated on: Fri, 21 February 2014 18:15]

Report message to a moderator

Previous Topic:close swr-rcp application without confirmation
Next Topic:Remove System In-Place Editor
Goto Forum:
  


Current Time: Tue Sep 23 22:27:43 GMT 2014

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

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