vazexqi / CodingSpectator

Watches and analyzes code edits in the Eclipse IDE non-invasively
http://codingspectator.cs.illinois.edu
Other
20 stars 14 forks source link

Some of the Reorg tests of JDT fail #179

Open reprogrammer opened 13 years ago

reprogrammer commented 13 years ago

The following tests from org.eclipse.jdt.ui.tests.refactoring.all.AllAllRefactoringTests fail.

The above tests fail with the following exception trace.

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
    at org.eclipse.swt.SWT.error(SWT.java:4083)
    at org.eclipse.swt.SWT.error(SWT.java:3998)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
    at org.eclipse.jdt.testplugin.JavaProjectHelper.emptyDisplayLoop(JavaProjectHelper.java:806)
    at org.eclipse.jdt.testplugin.JavaProjectHelper.delete(JavaProjectHelper.java:274)
    at org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup.tearDown(RefactoringTestSetup.java:85)
    at junit.extensions.TestSetup$1.protect(TestSetup.java:24)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.extensions.TestSetup.run(TestSetup.java:27)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
    at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.extensions.TestSetup.run(TestSetup.java:27)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
    at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:116)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.pde.internal.junit.runtime.UITestApplication.start(UITestApplication.java:47)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.NullPointerException
    at org.eclipse.mylyn.internal.monitor.ui.ActivityContextManager$3.run(ActivityContextManager.java:110)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    ... 49 more
reprogrammer commented 13 years ago

I changed org.eclipse.mylyn.internal.monitor.ui.ActivityContextManager.updateWorkingSetSelection() to the following.

protected void updateWorkingSetSelection() {
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (window != null) {
                IWorkbenchPage page = window.getActivePage();
                if (page != null)
                    workingSets = page.getWorkingSets();
            }
        }
    });
}

Simply, I add the check if (page != null). Surprisingly, this change fixed the NPE exception. Note that this change is outside the org.eclipse.jdt.ui.tests.refactoring and is inside the org.eclipse.mylyn.monitor.ui. And, I have no idea why we didn't encounter this problem before. However, this change makes all the refactoring tests pass without throwing any exceptions.

reprogrammer commented 13 years ago

I came across the same failing tests today. But, I couldn't find the source code of org.eclipse.mylyn.monitor.ui plug-in to apply our patch to. I couldn't even find the bytecode of any class called ActivityContextManager in my workspace. I have no idea why I couldn't find the class even though it's mentioned in the exception trace. We need to document the steps to checkout out the source code of this plug-in and applying the patch to it on the wiki page.