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

Bug 397290

Summary: NullPointerException in JUnitPreferencesConstants.parseList()
Product: [Eclipse Project] Equinox Reporter: Steffen Pingel <steffen.pingel>
Component: CompendiumAssignee: equinox.compendium-inbox <equinox.compendium-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Olivier_Thomann, remy.suen
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Steffen Pingel CLA 2013-01-01 16:00:04 EST
What steps will reproduce the problem?
1. Open Preferences
2. Navigate to Java > Junit page

The page does not open but the error below is logged.

-- Error Details --
Date: Tue Jan 01 21:57:05 CET 2013
Message: Problems occurred when invoking code from plug-in: "org.eclipse.jface".
Severity: Error
Product: Eclipse SDK 4.3.0.v201212250800 (org.eclipse.sdk.ide)
Plugin: org.eclipse.jface
Session Data:
eclipse.buildId=I20121225-0800
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA

Exception Stack Trace:
java.lang.NullPointerException
	at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
	at java.util.StringTokenizer.<init>(StringTokenizer.java:204)
	at org.eclipse.jdt.internal.junit.JUnitPreferencesConstants.parseList(JUnitPreferencesConstants.java:133)
	at org.eclipse.jdt.internal.junit.JUnitPreferencesConstants.getFilterPatterns(JUnitPreferencesConstants.java:140)
	at org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage.createActiveStackFiltersList(JUnitPreferencePage.java:776)
	at org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage$StackFilterContentProvider.<init>(JUnitPreferencePage.java:242)
	at org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage.createFilterTable(JUnitPreferencePage.java:422)
	at org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage.createStackFilterPreferences(JUnitPreferencePage.java:405)
	at org.eclipse.jdt.internal.junit.ui.JUnitPreferencePage.createContents(JUnitPreferencePage.java:346)
	at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:232)
	at org.eclipse.jface.preference.PreferenceDialog.createPageControl(PreferenceDialog.java:1502)
	at org.eclipse.jface.preference.PreferenceDialog$14.run(PreferenceDialog.java:1259)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1253)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(FilteredPreferenceDialog.java:675)
	at org.eclipse.jface.preference.PreferenceDialog$10.run(PreferenceDialog.java:709)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.preference.PreferenceDialog$9.selectionChanged(PreferenceDialog.java:705)
	at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:888)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:886)
	at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:1226)
	at org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(StructuredViewer.java:1251)
	at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:262)
	at org.eclipse.jface.util.OpenStrategy.access$5(OpenStrategy.java:256)
	at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:433)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3680)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3329)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.open(WorkbenchPreferenceDialog.java:215)
	at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:65)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3705)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3326)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1049)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:939)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:79)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:587)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:542)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	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:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1443)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1419)
Comment 1 Dani Megert CLA 2013-01-03 09:01:59 EST
I'll take a look.
Comment 2 Dani Megert CLA 2013-01-03 09:30:47 EST
Caused by bad fix for bug 387898. I reopened said bug.

*** This bug has been marked as a duplicate of bug 387898 ***
Comment 3 Remy Suen CLA 2013-01-03 10:20:55 EST
(In reply to comment #2)
> Caused by bad fix for bug 387898. I reopened said bug.

Thanks for finding the cause so quickly, Dani.

I was wondering if a different default value should be passed in as a parameter? While we expect the rest of the system to work (with JunitPreferenceInitializer properly defining a value in the preferences), would it be better to just play it safe here given that the return value is directly passed into StringTokenizer?
Comment 4 Dani Megert CLA 2013-01-03 10:30:48 EST
(In reply to comment #3)
> (In reply to comment #2)
> > Caused by bad fix for bug 387898. I reopened said bug.
> 
> Thanks for finding the cause so quickly, Dani.
> 
> I was wondering if a different default value should be passed in as a
> parameter? While we expect the rest of the system to work (with
> JunitPreferenceInitializer properly defining a value in the preferences),
> would it be better to just play it safe here given that the return value is
> directly passed into StringTokenizer?

No. We might never have discovered this bug otherwise.
Comment 5 Remy Suen CLA 2013-01-03 11:40:05 EST
(In reply to comment #4)
> (In reply to comment #3)
> > I was wondering if a different default value should be passed in as a
> > parameter? While we expect the rest of the system to work (with
> > JunitPreferenceInitializer properly defining a value in the preferences),
> > would it be better to just play it safe here given that the return value is
> > directly passed into StringTokenizer?
> 
> No. We might never have discovered this bug otherwise.

Now that the bug has been discovered, presumably a test that mimics the calls and behaviour of JDT's JUnit bundle would be added to prevent this though, no?
Comment 6 Dani Megert CLA 2013-01-03 11:48:06 EST
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > I was wondering if a different default value should be passed in as a
> > > parameter? While we expect the rest of the system to work (with
> > > JunitPreferenceInitializer properly defining a value in the preferences),
> > > would it be better to just play it safe here given that the return value is
> > > directly passed into StringTokenizer?
> > 
> > No. We might never have discovered this bug otherwise.
> 
> Now that the bug has been discovered, presumably a test that mimics the
> calls and behaviour of JDT's JUnit bundle would be added to prevent this
> though, no?

Sure, I expect that Equinox will add such a test ;-).
Comment 7 Steffen Pingel CLA 2013-01-03 12:07:58 EST
Is there a work-around? This problem renders the JUnit view unusable for me which I use quite a bit :).
Comment 8 John Arthorne CLA 2013-01-03 14:28:37 EST
(In reply to comment #3)
> I was wondering if a different default value should be passed in as a
> parameter? While we expect the rest of the system to work (with
> JunitPreferenceInitializer properly defining a value in the preferences),
> would it be better to just play it safe here given that the return value is
> directly passed into StringTokenizer?

Yes, this code makes the incorrect assumption that the default preference will always be the same as what was defined in the preference initializer. There are various mechanisms available to override the values set in a preference initializer extension: command line overrides, product level overrides, and even someone directly using API to alter the default scope values. IMO the NPE is legitimate bug to be fixed separately, but admittedly fairly unlikely to occur.
Comment 9 Dani Megert CLA 2013-01-04 03:24:53 EST
(In reply to comment #8)
> (In reply to comment #3)
> > I was wondering if a different default value should be passed in as a
> > parameter? While we expect the rest of the system to work (with
> > JunitPreferenceInitializer properly defining a value in the preferences),
> > would it be better to just play it safe here given that the return value is
> > directly passed into StringTokenizer?
> 
> Yes, this code makes the incorrect assumption that the default preference
> will always be the same as what was defined in the preference initializer.
> There are various mechanisms available to override the values set in a
> preference initializer extension: command line overrides, product level
> overrides, and even someone directly using API to alter the default scope
> values. IMO the NPE is legitimate bug to be fixed separately,

I tend to disagree. Yes, it could be overridden but in that case it would be "" and if someone really calls the API and removes our key then an NPE is an adequate punishment ;-).
Comment 10 Dani Megert CLA 2013-01-04 03:27:51 EST
(In reply to comment #7)
> Is there a work-around? This problem renders the JUnit view unusable for me
> which I use quite a bit :).

Either use M4 or switch to the latest N-build which has the issue fixed:
http://download.eclipse.org/eclipse/downloads/drops4/N20130103-2000/