Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351840

Summary: [Subclipse] Subclipse blocks Mylyn tests
Product: z_Archived Reporter: Steffen Pingel <steffen.pingel>
Component: MylynAssignee: Alvaro Sanchez-Leon <alvaro.sanchez-leon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 0.9   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Steffen Pingel CLA 2011-07-12 09:40:15 EDT
Since Subclipse was added to the target environment tests hang due to a modal dialog that is displayed by Subclipse during bundle activator.


Thread[Worker-5,5,main]
  java.lang.Object.wait(Native Method)
  org.eclipse.ui.internal.Semaphore.acquire(Semaphore.java:43)
  org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:168)
  org.eclipse.swt.widgets.Display.syncExec(Display.java:4282)
  org.tigris.subversion.subclipse.ui.Preferences.setSvnClientConfigDir(Preferences.java:60)
  org.tigris.subversion.subclipse.ui.Preferences.initializeFromSettings(Preferences.java:41)
  org.tigris.subversion.subclipse.ui.SVNUIPlugin.start(SVNUIPlugin.java:443)
  org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
  java.security.AccessController.doPrivileged(Native Method)
  org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
  org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
  org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
  org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)
  org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:417)
  org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:265)
  org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:106)
  org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:453)
  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
  org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393)
  org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
  org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
  java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:338)
  org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:232)
  org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1197)
  org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
  org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
  org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
  org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
  org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)
  org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:52)
  org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)
  org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition$1.run(LightweightDecoratorDefinition.java:124)
  org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
  org.eclipse.core.runtime.Platform.run(Platform.java:888)
  org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.internalGetDecorator(LightweightDecoratorDefinition.java:120)
  org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:251)
  org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:81)
  org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
  org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:365)
  org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:347)
  org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:371)
  org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:331)
  org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
  
Thread[main,6,main]
  org.eclipse.swt.internal.gtk.OS.Call(Native Method)
  org.eclipse.swt.widgets.Display.sleep(Display.java:4021)
  org.eclipse.jface.window.Window.runEventLoop(Window.java:826)
  org.eclipse.jface.window.Window.open(Window.java:801)
  org.tigris.subversion.subclipse.ui.Preferences$1.run(Preferences.java:63)
  org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
  org.eclipse.ui.internal.UILockListener.aboutToWait(UILockListener.java:126)
  org.eclipse.core.internal.jobs.LockManager.aboutToWait(LockManager.java:123)
  org.eclipse.core.internal.jobs.JobManager.join(JobManager.java:924)
  org.eclipse.mylyn.java.tests.AbstractJavaContextTest.waitForAutoBuild(AbstractJavaContextTest.java:104)
  org.eclipse.mylyn.java.tests.AbstractJavaContextTest.tearDown(AbstractJavaContextTest.java:96)
  org.eclipse.mylyn.java.tests.EditorManagerTest.tearDown(EditorManagerTest.java:70)
  junit.framework.TestCase.runBare(TestCase.java:140)
  junit.framework.TestResult$1.protect(TestResult.java:110)
  junit.framework.TestResult.runProtected(TestResult.java:128)
  junit.framework.TestResult.run(TestResult.java:113)
  junit.framework.TestCase.run(TestCase.java:124)
  junit.framework.TestSuite.runTest(TestSuite.java:232)
  junit.framework.TestSuite.run(TestSuite.java:227)
  junit.framework.TestSuite.runTest(TestSuite.java:232)
  junit.framework.TestSuite.run(TestSuite.java:227)
  junit.framework.TestSuite.runTest(TestSuite.java:232)
  junit.framework.TestSuite.run(TestSuite.java:227)
  org.eclipse.mylyn.commons.tests.support.ManagedTestSuite.run(ManagedTestSuite.java:144)
  org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
  org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
  org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
  org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
  org.apache.maven.surefire.Surefire.run(Surefire.java:177)
  org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:72)
  org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication$1.run(AbstractUITestApplication.java:35)
  org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
  org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
  org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
  org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
  org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
  org.eclipse.jface.window.Window.open(Window.java:801)
  org.tigris.subversion.subclipse.tools.usage.reporting.UsageReport.askUser(UsageReport.java:69)
  org.tigris.subversion.subclipse.tools.usage.reporting.UsageReport.access$2(UsageReport.java:65)
  org.tigris.subversion.subclipse.tools.usage.reporting.UsageReport$AskUserJob.runInUIThread(UsageReport.java:174)
  org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
  org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
  org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
  org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
  org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
  org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
  org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
  org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
  org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
  org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
  org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
  org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
  org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
  org.eclipse.tycho.surefire.osgibooter.UITestApplication.runApplication(UITestApplication.java:31)
  org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.run(AbstractUITestApplication.java:114)
  org.eclipse.tycho.surefire.osgibooter.UITestApplication.start(UITestApplication.java:37)
  org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  java.lang.reflect.Method.invoke(Method.java:597)
  org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
  org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
  org.eclipse.equinox.launcher.Main.run(Main.java:1408)
  org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Comment 1 Alvaro Sanchez-Leon CLA 2011-07-12 23:54:04 EDT
The subclipse connector has dependencies on subclipse.core not the ui.

Steffen, do you know what triggers the loading of the UI ?

We may need to take the Sublipse.core connector out of the nightly build while we figure it out.
Comment 2 Steffen Pingel CLA 2011-07-13 10:30:22 EDT
I merely added the Subclipse feature to the target environment but did not include the connector, yet.  I understand that we only need certain core plug-ins to build the connector but in order to run meaningful integration tests I prefer to consume dependencies on the feature level which includes the UI. We'll either need to tweak Subclipse during test setup to avoid the modal dialog or work with the Subclipse team to make changes upstream.

For now I have removed Subclipse from the target environment. Unfortunately, we won't be able to distribute the connector before this has been addressed.
Comment 3 Alvaro Sanchez-Leon CLA 2011-09-08 16:30:39 EDT
More info:
After checking the stack trace, and correlating it with Plug-in Selection spy, the dialog is the one explained at:
http://subclipse.tigris.org/usage.html

Next: I will prepare a preferences.ini file and see if this can be placed in the test environment to prevent this dialog.
Comment 4 Alvaro Sanchez-Leon CLA 2011-09-08 20:50:38 EDT
There are two possible work around found so far, not perfect but might be suitable for the test environment.

1) insert a a preferences.ini file in the plug-in jar file org.tigris.subversion.subclipse.tools.usage_1.0.1.jar
   content:
@org.tigris.subversion.subclipse.tools.usage=1.0.1
/instance/org.tigris.subversion.subclipse.tools.usage/ask_user_for_usage_report_preference=false

2) removing usage bundle from %ECLIPSE_HOME%\conf​iguration\org.eclip​se.equinox.simplecon​figurator\bundles.i​nfo
see http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=2728624

Steffen, do they seem suitable to use within the test environment ?
Comment 5 Steffen Pingel CLA 2011-09-13 08:51:53 EDT
Neither solution is going to work as the dialog also comes up when testing locally. Can you file a bug against Subclipse to suppress the prompt when running from unit tests? o.e.m.commons.core.CoreUtil.TEST_MODE has an example how to check that.
Comment 6 Alvaro Sanchez-Leon CLA 2011-09-13 10:22:44 EDT
(In reply to comment #5)
> Neither solution is going to work as the dialog also comes up when testing
> locally. Can you file a bug against Subclipse to suppress the prompt when
> running from unit tests? o.e.m.commons.core.CoreUtil.TEST_MODE has an example
> how to check that.

The following issue has been raised to subclipse:
http://subclipse.tigris.org/issues/show_bug.cgi?id=1302
Comment 7 Alvaro Sanchez-Leon CLA 2011-09-13 10:36:41 EDT
see initial comment from http://subclipse.tigris.org/issues/show_bug.cgi?id=1302

Steffen, could you extend on the limitations of why couldn't we exclude the following plug-in from the test environment:
     org.tigris.subversion.subclipse.tools.usage
     
It would be great if you could join the discussion in the subclipse bug, we can later summarize the outcome on a single comment on this one.
Comment 8 Steffen Pingel CLA 2011-09-15 08:31:32 EDT
Thanks for filing that. I have commented on the Subclipse bug report. 

I am lowering severity of this bug since Subclipse is not included in integration builds at this point and it's not clear yet if that is going to become a priority. Alvaro, if you add a test plug-in for Subclipse and we don't have another solution it would be great if you tried the approach in comment 4. It should be possible to tweak preferences in the test suite.
Comment 9 Steffen Pingel CLA 2011-09-18 16:28:54 EDT
Alvaro, are you able to provide a patch for Subclipse to suppress the modal dialogs when running in test mode?
Comment 10 Alvaro Sanchez-Leon CLA 2011-09-19 18:54:48 EDT
We need to sort our several issues before setting the preferences programatically from a test plug-in
1)  Bundle activation sequence, if the test plug-in uses early activation as the Usage plug-in does. 
   how can we make sure that we can set up the preferences before the usage plug-in fires the dialogue ?
   
2) The subclipse usage plug-in, does not export any of its packages, so  there is no public access to the plug-in to retrieve the preference store.

3) Comment 4 indicates possibilities to achieve this via the file system. this would require some sort of ant script to add the preferences.ini or remove the usage bundle as they are fetched from the repositories.  

Any ideas are very welcome.
Comment 11 Alvaro Sanchez-Leon CLA 2011-09-20 10:46:38 EDT
A new alternative to consider:
see http://wiki.eclipse.org/Steps_to_use_Fragments_to_patch_a_plug-in

The alternative above requires to wrap the original plug-in jar in another plug-in with the same identity, and 
modify the bundle properties to allow api extensions via a fragment, and giving higher priority to the loading of the fragment jar
  then the actual fragment can load a new version of a class and modify the behaviour.
   
I have done a quick test on this, and it would work, but the question is:

Since this approach wraps an external bundle it does not go well with the IP process, unless this is hosted on an external server.

Comments are very welcome
Comment 12 Steffen Pingel CLA 2011-09-21 07:05:36 EDT
Alvaro, any reason not to provide a patch for Subclipse so we don't have to deal with this problem at all?
Comment 13 Alvaro Sanchez-Leon CLA 2011-09-21 22:16:31 EDT
(In reply to comment #12)
> Alvaro, any reason not to provide a patch for Subclipse so we don't have to
> deal with this problem at all?

Comment 9 to Comment 11 are exploring the request in comment 8, to provide a test plug-in.  

As there no additional ideas on this. I will prepare a patch for the usage plug-in.
Comment 14 Steffen Pingel CLA 2011-09-22 05:54:16 EDT
All of your suggestions are very valid approaches but if feasible I prefer to address the root cause in Subclipse. Otherwise we'll end up having to apply the same work around in the various scenarios where tests are executed (e.g. local workspace).
Comment 15 Steffen Pingel CLA 2012-02-10 09:37:53 EST
I have updated the dev targets to include Subclipse 1.8 which appears to fix the observed problem.