Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312785 - [DataBinding] WizardPageSupport/DialogPageSupport can cause NPE when used with ValidationStatusProvider
Summary: [DataBinding] WizardPageSupport/DialogPageSupport can cause NPE when used wit...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-13 09:44 EDT by Matt Biggs CLA
Modified: 2020-05-25 17:27 EDT (History)
6 users (show)

See Also:


Attachments
patch fixing the NPE with tests (10.26 KB, patch)
2010-05-26 16:15 EDT, Ovidio Mallo CLA
no flags Details | Diff
same patch without auto formatting (5.78 KB, patch)
2010-05-31 16:32 EDT, Ovidio Mallo CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Biggs CLA 2010-05-13 09:44:44 EDT
Build Identifier: 20090920-1017

WizardPageSupport/DialogPageSupport attempts to dispose of ValidationStatusProvider and causes NPE.

I have a wizard where each page has its own DataBindingContext and i then use WizardPageSupport to provider the bindings/validation. The dispose() method of each wizard page calls dispose() on each of the databinding context. 

If a page contains a ValidationStatusProvider and the page is closed the WizardPageSupport attempts to remove the ValidationStatusProvider which has already been disposed of by the databinding context's disposal. As a result a NPE occurs. 

I'm unsure which should be responsible for disposing of everything.



java.lang.NullPointerException
	at org.eclipse.jface.databinding.dialog.DialogPageSupport.dispose(DialogPageSupport.java:322)
	at org.eclipse.jface.databinding.dialog.DialogPageSupport$6.handleEvent(DialogPageSupport.java:166)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1008)
	at org.eclipse.swt.widgets.Widget.release(Widget.java:804)
	at org.eclipse.swt.widgets.Widget.dispose(Widget.java:441)
	at org.eclipse.swt.widgets.Decorations.dispose(Decorations.java:447)
	at org.eclipse.swt.widgets.Shell.dispose(Shell.java:709)
	at org.eclipse.jface.window.Window.close(Window.java:335)
	at org.eclipse.jface.dialogs.Dialog.close(Dialog.java:979)
	at org.eclipse.jface.dialogs.TrayDialog.close(TrayDialog.java:179)
	at org.eclipse.jface.wizard.WizardDialog.hardClose(WizardDialog.java:807)
	at org.eclipse.jface.wizard.WizardDialog.close(WizardDialog.java:427)
	at org.eclipse.jface.wizard.WizardDialog.cancelPressed(WizardDialog.java:414)
	at org.eclipse.jface.wizard.WizardDialog$1.widgetSelected(WizardDialog.java:293)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
.....




Reproducible: Always
Comment 1 Matt Biggs CLA 2010-05-13 09:48:09 EDT
Additional info:

This only appears to occur when the wizard is cancelled.
Comment 2 Ovidio Mallo CLA 2010-05-26 16:15:04 EDT
Created attachment 170094 [details]
patch fixing the NPE with tests

Matt, the NPE is occuring only when the wizard is canceled since otherwise the uiChanged flag of the DialogPageSupport class is likely to be true in which case the code triggering the NPE is not executed.

Could you maybe check whether this patch solves the problem?
Comment 3 Matt Biggs CLA 2010-05-27 02:50:40 EDT
Ovidio,

Thanks for the patch, it seems to be fixing the problem! Is this likely to be able to make it into 3.6? 

cheers

matt
Comment 4 Ovidio Mallo CLA 2010-05-27 12:43:41 EDT
Matthew, Boris, do you think that this bug could/should be fixed for RC4?
Comment 5 Matthew Hall CLA 2010-05-27 14:09:02 EDT
+1 from me, this looks like a safe change.  Up to Boris on whether it's ok to push this patch at this stage of the release though.
Comment 6 Ovidio Mallo CLA 2010-05-31 15:53:18 EDT
Boris, do you think we could fix this for RC4?
Comment 7 Boris Bokowski CLA 2010-05-31 16:21:14 EDT
Could you attach a version of the patch without formatting changes?

Is this a regression?
Comment 8 Ovidio Mallo CLA 2010-05-31 16:32:58 EDT
Created attachment 170590 [details]
same patch without auto formatting
Comment 9 Ovidio Mallo CLA 2010-05-31 16:34:46 EDT
(In reply to comment #7)
> Could you attach a version of the patch without formatting changes?
Done.

> Is this a regression?
No, it's no regression bug.
Comment 10 Ovidio Mallo CLA 2010-05-31 16:54:10 EDT
What I'm just realising is that with my patch we might not always detach the validationStatusProviderTargetsListener within the DialogPageSupport#dispose() method on the target observable of a Binding (in case the Binding is already disposed) which might lead to problems.
Comment 11 Boris Bokowski CLA 2010-05-31 17:06:54 EDT
I would recommend not fixing in RC4. If we have lived with this for a whole release (probably longer), it rarely qualifies as something that needs fixing just before a release.

Is there a workaround that Matt could be using?
Comment 12 Matt Biggs CLA 2010-06-02 02:43:16 EDT
> Is there a workaround that Matt could be using?

A workaround would be much appreciated. I can't override the class and dispose() method due to the private variables used within the DialogPageSupport.

As it stands, with this issue, i have to cancel all wizards twice to remove them.
Comment 13 Boris Bokowski CLA 2010-06-02 11:06:47 EDT
Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix? After all, it's just a helper class.
Comment 14 Matt Biggs CLA 2010-06-02 11:09:52 EDT
(In reply to comment #13)
> Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix?
> After all, it's just a helper class.

I did think that may be an option. Its only 2 classes. Would this fix make it into 3.6 SR1 then?
Comment 15 Ovidio Mallo CLA 2010-06-02 13:20:53 EDT
Sorry for the delay, Matt. Another option might also be to make sure that the ValidationStatusProvider#getTargets() method does not return null after disposal. The only ValidationStatusProvider of the data binding framework which does this is MultiValidator so you might override MultiValidator (you must extend it anyway) and return an empty list instead of null in case the MultiValidator is disposed (see MultiValidator#isDisposed()).
Comment 16 Boris Bokowski CLA 2010-06-02 14:00:51 EDT
(In reply to comment #14)
> (In reply to comment #13)
> > Could you make your own copy of WizardPageSupport/DialogPageSupport with a fix?
> > After all, it's just a helper class.
> 
> I did think that may be an option. Its only 2 classes. Would this fix make it
> into 3.6 SR1 then?

Yes, fixing for 3.6.1 shouldn't be a problem.
Comment 17 Gemma Bowers CLA 2010-06-02 16:06:47 EDT
Thanks for the updates. 

Overriding the MultiValidator sounds interesting. ill have a look at that. 

Fixing for 3.6.1 would be much appreciated! Thanks.
Comment 18 Matt Biggs CLA 2010-06-02 16:13:46 EDT
(In reply to comment #17)
> Thanks for the updates. 
> 
> Overriding the MultiValidator sounds interesting. ill have a look at that. 
> 
> Fixing for 3.6.1 would be much appreciated! Thanks.

Interesting, i wrote that above comment but it appears my partner was logged in! oops.

Matt
Comment 19 Matt Biggs CLA 2010-06-03 04:10:14 EDT
Adding the following to the MultiValidator stops the NPE occuring. Thanks

@Override
public IObservableList getTargets() {
	/**
	 * BUGFIX: https://bugs.eclipse.org/bugs/show_bug.cgi?id=312785
	 */
	if( isDisposed() ) {
		return new ObservableList(Collections.emptyList(), null) {
		};
	}
	return super.getTargets();
}
Comment 20 Ovidio Mallo CLA 2010-06-03 12:34:56 EDT
(In reply to comment #19)
> Adding the following to the MultiValidator stops the NPE occuring. Thanks
I hope this temporary fix is OK for you for the time being.

BTW, you might also use Observables#emptyObservableList().
Comment 21 Matt Biggs CLA 2010-06-03 13:06:22 EDT
> BTW, you might also use Observables#emptyObservableList().


aha... i was looking for something like that, but couldn't find it. Thanks for the tip!
Comment 22 Matthew Hall CLA 2011-09-20 00:55:06 EDT
Ovidio, it looks like we're pretty close on this one, except we need a unit test for the TitleAreaDialog part. Can we push this through for M3?
Comment 23 Brian de Alwis CLA 2016-08-25 10:44:21 EDT
Ovido — I'd like to apply this patch.  Would it be possible for you to sign the Eclipse Contributors Agreement (https://wiki.eclipse.org/ECA)?
Comment 24 Eclipse Genie CLA 2020-05-25 17:27:19 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.