Community
Participate
Working Groups
Build ID: I20090313-0100 CDO and NET4J : 2.0.0M6 Steps To Reproduce: 1.Start an Eclipse SDK open a CDO Session, transaction, a resource... 2. Select an object, let's say "dummy object" 3. Right click, and lock it for instance writeLock. 4. Reproduce the same scenario on a second client connected to the same resource. When attempting to lock the object "dummy object" from this second client, a NPE is thrown. More information: The Lock operation is run through a LongRunningAction. This later one delegates to a Job. LongRunningAction.getShell() (to report the error message) is called from a NON UI thread. Hence, PlatformUI.getWorkbench().getActiveWorkbenchWindow() in LongRunningAction.getWorkbenchWindow() returns null and getShell() does not check that. To Fix that, I replace the Job by an UIJob in LongRunningAction.sageRun() that ensures to be in the UI thread. Other fixes are possible, I let you see the better way to fix that...
Can you provide the stack trace please ? Simon
Hi Simon, Here is the stack trace : java.lang.NullPointerException at org.eclipse.net4j.util.ui.actions.LongRunningAction.getShell(LongRunningAction.java:132) at org.eclipse.emf.cdo.internal.ui.actions.AbstractLockObjectsAction.doRun(AbstractLockObjectsAction.java:86) at org.eclipse.net4j.util.ui.actions.LongRunningAction$1.run(LongRunningAction.java:164) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Have a look at PlatformUI.getWorkbench().getActiveWorkbenchWindow() javadoc. It is clearly explained that this method returns null if there is no active workbench window or if called from a non-UI thread. In the other CDO UI actions, most of the time, LongRunningAction.getShell() is called in the preRun() method called from the UI Thread. But when LongRunningAction.getShell() is called to report to the end-user a message, the call is done within the Job.run(IProgressMonitor progressMonitor) which is in its own worker thread. The actions where this NPE can occur are : a) AbstractLockObjectsAction.doRun() b) OpenSessionAction.doRun() c) RegisterPackagesAction.doRun() Stephane.
Created attachment 130333 [details] Patch v1
Vic or Eike could review it. The problem was in the LongRunningAction. I added a getDisplay(). Simon
Created attachment 130334 [details] Patch v2 Forgot to change syncExec to asyncExec! :-)
Created attachment 130349 [details] Patch v3 Ready to be committed.
Committed to HEAD
Fix available in EMF CDO 2.0.0M6b
Generally available.