Bug 209830 - NullPointerException thrown
Summary: NullPointerException thrown
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.4.0 (Ganymede) M6   Edit
Assignee: Anthony Hunter CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-11-14 11:18 EST by ali afshar CLA
Modified: 2008-09-18 13:34 EDT (History)
4 users (show)

See Also:


Attachments
Patch trhowing SWTException (1012 bytes, patch)
2007-11-30 04:59 EST, Manuel Selva CLA
ahunter.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ali afshar CLA 2007-11-14 11:18:56 EST
Build id: I20070621-1340

GREEN WARNING: A critical error has occurred. You should copy this message along with the stack trace below and send it to the contact address provided with this software.
java.lang.NullPointerException
        at org.eclipse.draw2d.DeferredUpdateManager.sendUpdateRequest(DeferredUpdateManager.java:239)
        at org.eclipse.draw2d.DeferredUpdateManager.queueWork(DeferredUpdateManager.java:229)
        at org.eclipse.draw2d.DeferredUpdateManager.addInvalidFigure(DeferredUpdateManager.java:124)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.PolylineConnection.revalidate(PolylineConnection.java:215)
        at org.eclipse.draw2d.Figure.revalidate(Figure.java:1351)
        at org.eclipse.draw2d.Label.setText(Label.java:609)
        at edu.buffalo.cse.green.editor.controller.RelationshipPart.updateCardinalityLabel(RelationshipPart.java:371)
        at edu.buffalo.cse.green.editor.controller.RelationshipPart.access$0(RelationshipPart.java:363)
        at edu.buffalo.cse.green.editor.controller.RelationshipPart$RelationshipCardinalityHandler.notify(RelationshipPart.java:488)
        at edu.buffalo.cse.green.editor.model.AbstractModel.firePropertyChange(AbstractModel.java:269)
        at edu.buffalo.cse.green.editor.model.RelationshipModel.updateCardinality(RelationshipModel.java:540)
        at edu.buffalo.cse.green.editor.DiagramEditor.refreshRelationships(DiagramEditor.java:1396)
        at edu.buffalo.cse.green.editor.DiagramEditor.forceRefreshRelationships(DiagramEditor.java:1333)
        at edu.buffalo.cse.green.JavaModelListener.elementChanged(JavaModelListener.java:158)
        at org.eclipse.jdt.internal.core.DeltaProcessor$3.run(DeltaProcessor.java:1552)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
        at org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(DeltaProcessor.java:1542)
        at org.eclipse.jdt.internal.core.DeltaProcessor.fireReconcileDelta(DeltaProcessor.java:1395)
        at org.eclipse.jdt.internal.core.DeltaProcessor.fire(DeltaProcessor.java:1350)
        at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:761)
        at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:780)
        at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1169)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:101)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:82)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:149)
        at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
        at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:96)
        at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:75)
        at org.eclipse.jdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:378)
        at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
Comment 1 Anthony Hunter CLA 2007-11-14 12:59:23 EST
The NPE is in Display.getCurrent().asyncExec(new UpdateRequest());

Almost definitely the Display.getCurrent() in null as you are trying to run on a non UI thread.

You need to fix your notification listener to run the UI updates on the UI thread.

In theory we could add some protection code so that the NPE is not thrown.
Comment 2 Pratik Shah CLA 2007-11-14 14:41:56 EST
Making changes outside the UI thread can cause several problems.  This is a good way to bring to the client's attention that they're doing something unintended.
Comment 3 David Williams CLA 2007-11-14 16:01:04 EST
(In reply to comment #2)
> Making changes outside the UI thread can cause several problems.  This is a
> good way to bring to the client's attention that they're doing something
> unintended.
> 

Gee ... wouldn't an "invalid thread access" exception be better? :) 
Comment 4 Pratik Shah CLA 2007-11-16 01:18:42 EST
Yeah, you're right, that would be better.  At least that will stop clients from opening such invalid defects.
Comment 5 Anthony Hunter CLA 2007-11-16 09:55:23 EST
We should fix to throw an "invalid thread access" exception when this issue occurs.
Comment 6 Manuel Selva CLA 2007-11-30 04:59:16 EST
Created attachment 84150 [details]
Patch trhowing SWTException
Comment 7 Manuel Selva CLA 2007-11-30 05:00:23 EST
Hi all,

Please Find attached a patch throwing an SWTException with the
INVALID_THREAD_ACCESS code when trying to get the current display from a non UI
thread.

I am not sure this the good exception to throw ... maybe we have to create a
new "Exception" or use an existing draw2d's one ... ???

Manuel
Comment 8 Manuel Selva CLA 2008-02-29 08:29:50 EST
Any news about the submitted patch ??

Manuel
Comment 9 Anthony Hunter CLA 2008-02-29 08:58:32 EST
OK, we will get this one into 3.4.
Comment 10 Manuel Selva CLA 2008-02-29 09:04:23 EST
Cool ;o)
  
I also ran into the same problem than David and really think that if would prevent clients from doing wrong as said above.
  
Thanks
Comment 11 Pratik Shah CLA 2008-02-29 09:16:46 EST
I think throwing an SWTException might act as a red herring, and cause requests/bugs to be reported against SWT.  Perhaps we should throw a java.lang.IllegalAccessException (or something similar) instead.
Comment 12 Anthony Hunter CLA 2008-03-26 15:28:22 EDT
(In reply to comment #11)
> I think throwing an SWTException might act as a red herring, and cause
> requests/bugs to be reported against SWT.  Perhaps we should throw a
> java.lang.IllegalAccessException (or something similar) instead.
> 

Upon review, SWTException(SWT.ERROR_THREAD_INVALID_ACCESS) would be the correct exception.

There are no others exceptions that I can find that are more appropriate. IllegalAccessException refers to illegal accessing fields and methods.