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/IContributionManager.java
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.action;
/**
 * A contribution manager organizes contributions to such UI components
 * as menus, toolbars and status lines.
 * <p>
 * A contribution manager keeps track of a list of contribution
 * items. Each contribution item may has an optional identifier, which can be used
 * to retrieve items from a manager, and for positioning items relative to
 * each other. The list of contribution items can be subdivided into named groups 
 * using special contribution items that serve as group markers.
 * </p>
 * <p>
 * The <code>IContributionManager</code> interface provides general
 * protocol for adding, removing, and retrieving contribution items.
 * It also provides convenience methods that make it convenient
 * to contribute actions. This interface should be implemented
 * by all objects that wish to manage contributions.
 * </p>
 * <p>