[jbosstools-issues] [JBoss JIRA] Commented: (JBIDE-2128) Error when executing the testCAforIncludeTaglibInInenerNodes VPE JUnit test

Snjezana Peco (JIRA) jira-events at lists.jboss.org
Sun Apr 27 17:03:15 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBIDE-2128?page=comments#action_12410859 ] 
            
Snjezana Peco commented on JBIDE-2128:
--------------------------------------

There is a basic issue in the VpeUtil.waitForJobs method which causes this issue as well as the issue that happens randomly when executing testJBIDE1105.

The VpeUtil.waitForJobs method:

/**
 * Wait until all background tasks are complete.
*/
public static void waitForJobs() {
	while (Job.getJobManager().currentJob() != null)
		delay(100);
}

doesn't wait for all background tasks to be complete. It takes into consideration only those jobs that are running in the current thread. 

The following is from javadoc for the currentJob method :

"Returns the job that is currently running in this thread, or null if there is no currently running job.
Returns:
    the job or null"

The following is the correct method that waits "until all background jobs are complete":

public static void waitForIdle() {
	while (!Job.getJobManager().isIdle())
		delay(100);
}

Using this method  may cause an issue if there is a job that is incorrectly implemented (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=198241)

I have implemented the method to detect such cases:

public static void waitForIdle() {
	long start = System.currentTimeMillis();
	while (!Job.getJobManager().isIdle()) {
		delay(500);
		if ( (System.currentTimeMillis()-start) > MAX_IDLE ) 
			throw new RuntimeException("A long running task detected");
	}
}

I have set MAX_IDLE=1800000 (30 min) because some of our tasks take a long time. Since our jobs don't have the problem described in the Eclipse/Mylyn bug, they will never take 30 min. If somebody adds such a job, the method will detect it.
If we use this method, we will be able to remove the TestUtil.delay() method in many places in the code (I have removed TestUtil.delay(10000L) and TestUtil.delay(15000L) in the testJBIDE1479). 
This will also solve the issues happening because a validator and reconciler are running in a non-UI thread. The waitForJobs method takes into consideration only those jobs that are running in the UI thread. Those issues manifest in the way that we randomly get an exception (NPE oftenest) when executing tests. The exception contains some WTP's (or Seam validator's) stack trace.  

I have added this method in the testJBIDE1105 and testJBIDE1479 tests because of the current errors in the VPE tests, but think that the waitForJobs method needs to be replaced with the waitForIdle method everywhere.


> Error when executing the testCAforIncludeTaglibInInenerNodes VPE JUnit test
> ---------------------------------------------------------------------------
>
>                 Key: JBIDE-2128
>                 URL: http://jira.jboss.com/jira/browse/JBIDE-2128
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: Visual Page Editor
>    Affects Versions: 2.1.0.beta1
>            Reporter: Snjezana Peco
>         Assigned To: Snjezana Peco
>            Priority: Minor
>
> Sometimes, the VpeController.notifyChanged method is called when the VPE is disposed. This causes NPE.
> The solution is to check if the editor is disposed and, if it is,.not to execute the method.
> This error occurs randomly.
> Stack trace:
> Failed to execute runnable (java.lang.NullPointerException)
> org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
> at org.eclipse.swt.SWT.error(SWT.java:3563)
> at org.eclipse.swt.SWT.error(SWT.java:3481)
> at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3296)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2974)
> at org.jboss.tools.vpe.ui.test.TestUtil.delay(TestUtil.java:144)
> at org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test.baseCheckofCA(JBIDE788Test.java:243)
> at org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test.testCAforIncludeTaglibInInenerNodes(JBIDE788Test.java:56)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> at junit.extensions.TestSetup.run(TestSetup.java:25)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:354)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:206)
> at org.eclipse.test.UITestApplication$3.run(UITestApplication.java:195)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:129)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3296)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2974)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
> at org.eclipse.test.UITestApplication.runApplication(UITestApplication.java:138)
> at org.eclipse.test.UITestApplication.run(UITestApplication.java:60)
> at org.eclipse.test.UITestApplication.start(UITestApplication.java:210)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
> at org.eclipse.core.launcher.Main.main(Main.java:30)
> Caused by: java.lang.NullPointerException
> at org.jboss.tools.vpe.editor.VpeController$ActiveEditorSwitcher.access$3(VpeController.java:1479)
> at org.jboss.tools.vpe.editor.VpeController.notifyChangedInUiThread(VpeController.java:440)
> at org.jboss.tools.vpe.editor.VpeController$2.runInUIThread(VpeController.java:428)
> at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:94)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:129)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbosstools-issues mailing list