Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334993 - [DataBinding] Binding.disposeListener should check if binding is already disposed
Summary: [DataBinding] Binding.disposeListener should check if binding is already disp...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-21 06:19 EST by Tonny Madsen CLA
Modified: 2019-10-19 17:41 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tonny Madsen CLA 2011-01-21 06:19:33 EST
When using multiple dispose listener for the same observable, a later listener in the list can occasionally be called after the observable has been disposed completely.

In this case the disposeListener of Binding can be called with context == null resulting in an NPE.

To solve this change the code of Binding.init() to

	public final void init(DataBindingContext context) {
		this.context = context;
		if (target.isDisposed())
			throw new IllegalArgumentException("Target observable is disposed"); //$NON-NLS-1$
		if (model.isDisposed())
			throw new IllegalArgumentException("Model observable is disposed"); //$NON-NLS-1$
		this.disposeListener = new IDisposeListener() {
			public void handleDispose(DisposeEvent staleEvent) {
				if (isDisposed()) return;
				Binding.this.context.getValidationRealm().exec(new Runnable() {
					public void run() {
						if (!isDisposed())
							dispose();
					}
				});
			}
		};
		target.addDisposeListener(disposeListener);
		model.addDisposeListener(disposeListener);
		preInit();
		context.addBinding(this);
		postInit();
	}



-- Configuration Details --
Product: Eclipse 1.3.1.20100913-1228 (org.eclipse.epp.package.rcp.product)
Installed Features:
 org.eclipse.platform 3.6.1.r361_v20100909-9gF78GrkFqw7GrsZnvz0JWNTeb6fue6896L
Comment 1 Tonny Madsen CLA 2011-01-21 06:46:36 EST
Example missing:

- create observable a.
- create observable z.
- add dispose listener, L, to a that will dispose of z.
- add binding between a and z. This is also add a dispose listener to both a and z: baL and bzL

When a is disposed, you'll get:

- dispose listeners of a found: L plus baL.
- L is called, which disposes z.
  - dispose listeners of z found:; bzL
  - bzL called, which disposes b (including setting context to null).
-baL called, but now context is null!!!!
Comment 2 Tonny Madsen CLA 2011-04-29 05:56:52 EDT
Any change for a fix for this in 3.7?
Comment 3 Eclipse Genie CLA 2019-10-19 17:41:27 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.

If you have further information on the current state of the bug, please add it. 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.