Project: JDT
Bug 411841 Rerunning a test from JUnit results view is launching the test on UI thread.
Reported: 2013-06-27 19:03:40 | Status: resolved fixed

When I rerun a test by selecting "Run" from the JUnit test results view context menu the test launch is happening on the UI thread. When build before launch is enabled the project build is invoked on UI thread on Eclipse is frozen during the test launch process. I am working on a patch to avoid it by delegating the rerun config launching to DebugUITools.launch() and will attach it to the bug soon. A sample stack trace captured during the freeze is ... java.io.UnixFileSystem.createDirectory(Native Method) java.io.File.mkdir(File.java:1239) java.io.File.mkdirs(File.java:1266) org.eclipse.core.internal.filesystem.local.LocalFile.mkdir(LocalFile.java:286) org.eclipse.core.internal.localstore.FileSystemResourceManager.write(FileSystemResourceManager.java:1132) org.eclipse.core.internal.resources.Folder.internalCreate(Folder.java:180) org.eclipse.core.internal.resources.Folder.create(Folder.java:107) org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.createFolder(AbstractImageBuilder.java:470) org.eclipse.jdt.internal.core.builder.AbstractImageBuilder$1.visit(AbstractImageBuilder.java:254) org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:85) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86) org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127) org.eclipse.core.internal.resources.Resource.accept(Resource.java:95) org.eclipse.core.internal.resources.Resource.accept(Resource.java:52) org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.addAllSourceFiles(AbstractImageBuilder.java:219) org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:51) org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254) org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:184) org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256) org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:394) org.eclipse.core.internal.resources.Project$1.run(Project.java:618) org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597) org.eclipse.core.internal.resources.Project.build(Project.java:114) org.eclipse.debug.core.model.LaunchConfigurationDelegate$1.run(LaunchConfigurationDelegate.java:423) org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2326) org.eclipse.debug.core.model.LaunchConfigurationDelegate.buildProjects(LaunchConfigurationDelegate.java:430) org.eclipse.debug.core.model.LaunchConfigurationDelegate.buildForLaunch(LaunchConfigurationDelegate.java:126) org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:823) org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704) org.eclipse.jdt.internal.junit.model.TestRunSession.rerunTest(TestRunSession.java:485) org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.rerunTest(TestRunnerViewPart.java:2062) org.eclipse.jdt.internal.junit.ui.RerunAction.run(RerunAction.java:52) org.eclipse.jface.action.Action.runWithEvent(Action.java:498) org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276) org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3554) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3179)

Files changed in fix:
org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java