Bug 206179 [Contributions] null pointer referenced is not caught when adding an action/item to menu in org.eclipse.jface.action.ContributionManager
If an error in ApplicationActionBarAdivosor-class occurs the application is just terminated, but does not throw an exception on console, even not in debug mode. Example: Save Action. When the save action is not created in the RCP's ActionBarAdvisor, but tried to be added to the menu the application is just terminated. A possible solution might be the modification of the both add-methods in org.eclipse.jface.action.ContributionManager: /* * (non-Javadoc) Method declared on IContributionManager. */ public void add(IAction action) { try{ add(new ActionContributionItem(action)); } catch(NullPointerException e){ ILog log = Platform.getLog(JFaceActivator.getBundle()); String message = "The action element pointed to null."; //$NON-NLS-1$ log.log(new Status(IStatus.ERROR, String.valueOf(JFaceActivator.getBundle().getBundleId()), message,e )); } } /* * (non-Javadoc) Method declared on IContributionManager. */ public void add(IContributionItem item) { try{ if (allowItem(item)) { contributions.add(item); itemAdded(item); } } catch(NullPointerException e){ ILog log = Platform.getLog(JFaceActivator.getBundle()); String message = "The item has a null-reference"; //$NON-NLS-1$ log.log(new Status(IStatus.ERROR, String.valueOf(JFaceActivator.getBundle().getBundleId()), message,e )); } }
bundles/org.eclipse.jface/src/org/eclipse/jface/action/ContributionManager.java
* prevent certain items in the contributions list.
	 * <code>ContributionManager</code> will either block or allow an addition
	 * based on the result of this method call. This can be used to prevent
	 * duplication, for example.
	 * 
	 * @param itemToAdd
	 *            The contribution item to be added; may be <code>null</code>.
	 * @return <code>true</code> if the addition should be allowed;
	 *         <code>false</code> otherwise. The default implementation allows
	 *         all items.
	 * @since 3.0
	 */
	protected boolean allowItem(IContributionItem itemToAdd) {
		return true;
	}
	/**
	 * Internal debug method for printing statistics about this manager to
	 * <code>System.out</code>.
	 */
	protected void dumpStatistics() {
		int size = 0;
		if (contributions != null) {
			size = contributions.size();
		}
		System.out.println(this.toString());
		System.out.println("   Number of elements: " + size);
		int sum = 0;
		for (int i = 0; i < size; i++) {
			if (((IContributionItem) contributions.get(i)).isVisible()) {
				sum++;