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