Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » StackOverflowError with databinding
StackOverflowError with databinding [message #1743274] Tue, 13 September 2016 17:57 Go to next message
Xavipen Mising name is currently offline Xavipen Mising nameFriend
Messages: 57
Registered: March 2011
Member
Hi,

I have started to see the following error in my RAP application. It seems related to an update that causes a recursive call to the same methods. I am a bit clueless on what can be causing it.

The stack trace is as follows (the end is repeated several times but for clarity i have avoided adding it here):

10:47:27.928 [UIThread [53b62d0b]] ERROR com.lsespace.ssp.SSPWorkbenchAdvisor - Problem occurred on platform: Unhandled event loop exception
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StackOverflowError)
	at org.eclipse.swt.SWT.error(SWT.java:3658) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.swt.SWT.error(SWT.java:3581) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:186) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1200) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.swt.widgets.Display.safeReadAndDispatch(Display.java:1180) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1172) ~[p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:701) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) [p2.eclipse-plugin.org.eclipse.core.databinding.observable-1.5.0.v20150422-0725.jar:na]
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:684) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at com.lsespace.ssp.SSPApp.start(SSPApp.java:22) [com.lsespace.ssp/:na]
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38) [p2.eclipse-plugin.org.eclipse.rap.ui.workbench-3.0.2.20160120-1649.jar:na]
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:171) [p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:283) [p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:104) [p2.eclipse-plugin.org.eclipse.rap.rwt-3.0.2.20160201-1220.jar:na]
Caused by: java.lang.StackOverflowError: null
	at java.util.zip.ZipCoder.getBytes(ZipCoder.java:86) ~[na:1.8.0_51]
	at java.util.zip.ZipFile.getEntry(ZipFile.java:311) ~[na:1.8.0_51]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.getZipEntry(ZipBundleFile.java:115) ~[na:na]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.getEntry(ZipBundleFile.java:234) ~[na:na]
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:562) ~[na:na]
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540) ~[na:na]
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527) ~[na:na]
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324) ~[na:na]
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:327) ~[na:na]
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:402) ~[na:na]
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352) ~[na:na]
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344) ~[na:na]
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160) ~[na:na]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_51]
	at org.eclipse.core.databinding.ValueBinding$2.handleValueChange(ValueBinding.java:58) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java:74) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.notifyIfChanged(SimplePropertyObservableValue.java:127) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.doGetValue(SimplePropertyObservableValue.java:103) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.getValue(AbstractObservableValue.java:80) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding$3.run(ValueBinding.java:165) ~[na:na]
	at org.eclipse.core.databinding.observable.Realm$1.run(Realm.java:150) ~[na:na]
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) ~[na:na]

	at org.eclipse.core.databinding.observable.Realm.safeRun(Realm.java:154) [p2.eclipse-plugin.org.eclipse.core.databinding.observable-1.5.0.v20150422-0725.jar:na]
	at org.eclipse.core.databinding.observable.Realm.exec(Realm.java:172) [p2.eclipse-plugin.org.eclipse.core.databinding.observable-1.5.0.v20150422-0725.jar:na]
	at org.eclipse.core.databinding.ValueBinding.doUpdate(ValueBinding.java:158) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding.access$4(ValueBinding.java:147) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding$2.handleValueChange(ValueBinding.java:56) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java:74) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.notifyIfChanged(SimplePropertyObservableValue.java:127) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.doGetValue(SimplePropertyObservableValue.java:103) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.getValue(AbstractObservableValue.java:80) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding$3.run(ValueBinding.java:165) ~[na:na]
	at org.eclipse.core.databinding.observable.Realm$1.run(Realm.java:150) ~[na:na]
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) ~[na:na]

	at org.eclipse.core.databinding.observable.Realm.safeRun(Realm.java:154) [p2.eclipse-plugin.org.eclipse.core.databinding.observable-1.5.0.v20150422-0725.jar:na]
	at org.eclipse.core.databinding.observable.Realm.exec(Realm.java:172) [p2.eclipse-plugin.org.eclipse.core.databinding.observable-1.5.0.v20150422-0725.jar:na]
	at org.eclipse.core.databinding.ValueBinding.doUpdate(ValueBinding.java:158) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding.access$4(ValueBinding.java:147) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding$2.handleValueChange(ValueBinding.java:56) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.fireValueChange(DecoratingObservableValue.java:57) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.handleValueChange(DecoratingObservableValue.java:99) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue$1.handleValueChange(DecoratingObservableValue.java:72) ~[na:na]
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:63) ~[na:na]
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java:74) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.notifyIfChanged(SimplePropertyObservableValue.java:127) ~[na:na]
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.doGetValue(SimplePropertyObservableValue.java:103) ~[na:na]
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.getValue(AbstractObservableValue.java:80) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.observable.value.DecoratingObservableValue.getValue(DecoratingObservableValue.java:105) ~[na:na]
	at org.eclipse.core.databinding.ValueBinding$3.run(ValueBinding.java:165) ~[na:na]
	at org.eclipse.core.databinding.observable.Realm$1.run(Realm.java:150) ~[na:na]
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) ~[na:na]


Any advise to point me to the right direction to troubleshoot this will be highly appreciated. The first lines of the stack trace are changing bu the rest is allways the same block of calls. Somehow it seems to be stuck calling ValueBinding.doUpdate(ValueBinding.java:158) ~[na:na] recuersively till it eventually throws the StackOverflowError

I am using the following p2 repositories for my target platform:
rap-3.0: http://download.eclipse.org/rt/rap/3.0/SR2-20160201-1220
eclipse-mars: http://download.eclipse.org/eclipse/updates/4.5/R-.5.2-201602121500

Thanks in advance
Re: StackOverflowError with databinding [message #1743552 is a reply to message #1743274] Fri, 16 September 2016 10:15 Go to previous message
Xavipen Mising name is currently offline Xavipen Mising nameFriend
Messages: 57
Registered: March 2011
Member
I continue investigating the issue and i have found where is the problem.

I have a bean with some properties that can have a very High rate of updates. 500.000 or more a second. The bean bunches this updates and only calls its PropertyChangeListeners once every 500ms. However actual value of the property is changed very often.

On RAP, the client is set to pool every second to update the GUI. This triggers the execution of the ValueBinding.doUpdate(). So far so good and most of the times it is like this. However not always.

For extra information, this is how the ValueBinding is created:

		IObservableValue modelElement = BeanProperties.value(field).observe(bean);
		IObservableValue uiElement = WidgetProperties.text(SWT.Modify).observe(txtWidget);

bindingContext.bindValue(uiElement,
				modelElement, targetToModelUpdateStrategy,
				modelToTargetUpdateStrategy);

The issue is starts with the get value
// Get value
Object value = source.getValue()

This ends up calling the SimplePropertyObservableValue doGetValue method which calls the notifyIfChanged(null). This call to the notifyIfChanged if the one causing the stackOverflowError. The explanation is in comment lines in the code below


	@Override
	protected Object doGetValue() {
		notifyIfChanged(null);
		return property.getValue(source);
	}


	private void notifyIfChanged(ValueDiff diff) {
		if (hasListeners()) {
			Object oldValue = cachedValue;

//The property value is changed at a high rate of updates on a different thread.
//This causes a race condition. 
// cachedValue updates to new value and fires the valueChange.
//second run this code gets call again but not fast enough so the property value has changed. This means fireValuChanged is called again.
// second run can repeat infinite times and causes StackOverflowError eventually.
			Object newValue = cachedValue = property.getValue(source);
			if (diff == null)
				diff = Diffs.createValueDiff(oldValue, newValue);
			if (!Util.equals(oldValue, newValue) || stale) {
				stale = false;
				fireValueChange(diff);
			}
		}
	}



Normally the code above would be fine for most of the properties of a bean, but for this case it does not work. I guess it should be a save guard to avoid the recuesive loop and break it at some point to avoid the StackOverflowError.

for example, would do:

 
       boolean getFiredUpdate = false;
       @Override
	protected Object doGetValue() {
               if ( !getFiredUpdate ) {
                        getFiredUpdate = true;
		        notifyIfChanged(null);
                }
                getFiredUpdate = false;
		return property.getValue(source);
	}


The issue does not allways ends up in StackOverflowError but it can cause 30 recursives calls before the value is updated.

Could any one point me to an easy way of workaround this issue?
Should a bug report be open for this?

Regards,
Xavi
Previous Topic:Viewers
Next Topic:Best way to open a TreeViewer
Goto Forum:
  


Current Time: Fri Sep 21 15:18:33 GMT 2018

Powered by FUDForum. Page generated in 0.02244 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top