Bug 128814 - [prefs] NPEs in log during tests
Summary: [prefs] NPEs in log during tests
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-21 10:22 EST by John Arthorne CLA
Modified: 2006-03-28 10:54 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2006-02-21 10:22:46 EST
In the following build output:

http://fullmoon/eclipse/downloads/drops/N20060221-0010/testresults/consolelogs/macosx.carbon_consolelog.txt

There are a large number of NPEs. These are caused by EclipsePreferences.put being called with a null parameter.


Full stack trace:

java.lang.NullPointerException
 at org.eclipse.core.internal.preferences.EclipsePreferences.put(EclipsePreferences.java:758)
 at org.eclipse.jdt.internal.core.JavaModelManager$EclipsePreferencesListener.preferenceChange(JavaModelManager.java:1006)
 at org.eclipse.core.internal.preferences.EclipsePreferences$2.run(EclipsePreferences.java:746)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
 at org.eclipse.core.internal.preferences.EclipsePreferences.firePreferenceEvent(EclipsePreferences.java:749)
 at org.eclipse.core.internal.preferences.EclipsePreferences.put(EclipsePreferences.java:762)
 at org.eclipse.jdt.internal.core.JavaModelManager.variablePut(JavaModelManager.java:3918)
 at org.eclipse.jdt.internal.core.JavaModelManager.updateVariableValues(JavaModelManager.java:3810)
 at org.eclipse.jdt.core.JavaCore.setClasspathVariables(JavaCore.java:4306)
 at org.eclipse.jdt.core.JavaCore.setClasspathVariable(JavaCore.java:4271)
 at org.eclipse.jdt.core.tests.model.ClasspathInitializerTests$DefaultVariableInitializer.initialize(ClasspathInitializerTests.java:44)
 at org.eclipse.jdt.core.tests.model.VariablesInitializer.initialize(VariablesInitializer.java:43)
 at org.eclipse.jdt.core.JavaCore.getClasspathVariable(JavaCore.java:1584)
 at org.eclipse.jdt.core.tests.model.ClasspathInitializerTests.testVariableInitializer11(ClasspathInitializerTests.java:898)
Comment 1 Frederic Fusier CLA 2006-02-27 07:47:08 EST
Fixed and released in HEAD.

To avoid polluting messages in console, I added a null check on option value before reset it.

Olivier, if you have any time, I will be really interested in having feedback on reason why property value is null only on Mac/OS box, TIA
Comment 2 Olivier Thomann CLA 2006-02-27 13:37:35 EST
Changing title since this is not related to Mac. Same errors occur on Windows and Linux.
This needs more investigation. Right now executing testVariableInitializer01 before testVariableInitializer02 is different from executing only testVariableInitializer02. testVariableInitializer01 has a side-effect when executing testVariableInitializer02.
The javamodel.variablesWithInitializer field doesn't have the same value if testVariableInitializer02 is run alone or testVariableInitializer01 is executed first when running testVariableInitializer02.
A test should not be dependant or affected by the execution of another test.
Comment 3 Frederic Fusier CLA 2006-02-27 16:53:09 EST
Problem comes from the fact that variables were not removed from JavaModelManager variablesWithInitializer cache when their value was reset. This was intentionally done as I thought that initializers may only be specified in extensions and so cannot be removed during an eclipse session.

I was obviously wrong as users can use JavaCore API programatically (as we do in our tests!) and add/remove initializers... So, the fix is to remove the variable name from this cache when the value is set to null in putVariable(...) method in JavaModelManager..

Note that remove this variable name from cache before updating eclipse preferences also avoid to call preferences listener with a wrong value and avoid to refresh preferences unnecessarily (see fix for bug 125965).

I keep null check as ultimate protection => in this case, variable name is removed from cache...
Comment 4 Frederic Fusier CLA 2006-02-27 16:54:56 EST
Fixed and released in HEAD.
Comment 5 Olivier Thomann CLA 2006-03-28 10:54:48 EST
Verified using I20060328-0010 for 3.2M6 since tests passed for a long time now.