Community
Participate
Working Groups
Build Identifier: 20110615-0604 I am programmatically implementing my own context help by creating an AbstractContextProvider that returns my own IContext implementation. The Javadoc for IContext.getRelatedTopics states that it is allowed to return null when there are no related topics. However when I return null, I get a NullPointerException when opening the context sensitive help in a preference page: java.lang.NullPointerException at org.eclipse.help.internal.context.Context.mergeContext(Context.java:66) .... This is because there is a for loop over the value returned by getRelatedTopics. Either this implementation needs to check for nulls or the javadoc should be adjusted to state that nulls are illegal. Workaround: simply return new IHelpResource[0] Reproducible: Always Steps to Reproduce: 1. Create your own context provider and register it with extension point org.eclipse.help.contexts 2. Let it return an IContext implementation that returns null on getRelatedTopics() 3. Create a preference page that sets this context on Composite parent in the createControl method. 4. Open the preference page and press the help key (F1 on windows)
Not sure if it is easily reproducible by these steps because it probably only occurs when ContextFileProvider.getContext decides to merge contexts. I have overwritten org.eclipse.ui.preference_dialog_context. However if the Javadoc is changed the bug is quickly fixed and doesn't need to get reproduced.
You are correct, it is a bug. Targeting Eclipse 3.8 - since there is an easy workaround there is no need to fix in 3.7.1.
It appears that there are at least three locations where the result of this function is used without testing from null. I will edit the javadoc to state that the result cannot be null.
The documentation change has been committed with message: Bug 351176 - [Doc] NullPointerException when implementing IContext.getRelatedTopics to return null