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

Bug 329595

Summary: [target] NPE in TargetContentsGroup.getBundleChildren
Product: [Eclipse Project] PDE Reporter: Jeff McAffer <jeffmcaffer>
Component: UIAssignee: PDE-UI-Inbox <pde-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Jeff McAffer CLA 2010-11-05 17:12:53 EDT
TargetContentsGroup.getBundleChildren calls to 
			IBundleContainer container = (IBundleContainer) parent;
			return container.getBundles();
getBundles can return null but callers of getBundleChildren are not expecting null.  Changing the method to read

	private Object[] getBundleChildren(Object parent) {
		Object[] result = null;
		if (parent == null) {
			result = fAllBundles.toArray();
		} else if (fFeaureModeButton.getSelection() && parent == OTHER_CATEGORY) {
			result = ((TargetDefinition) fTargetDefinition).getOtherBundles();
		} else if (fGrouping == GROUP_BY_CONTAINER && parent instanceof IBundleContainer) {
			IBundleContainer container = (IBundleContainer) parent;
			result = container.getBundles();
		} else if (fGrouping == GROUP_BY_FILE_LOC && parent instanceof IPath) {
			List bundles = (List) getFileBundleMapping().get(parent);
			if (bundles != null && bundles.size() > 0) {
				result = bundles.toArray();
			}
		}
		if (result == null) {
			return new Object[0];
		}
		return result;
	}

Here the two returns in the if/else statements were changed to result = .  Then the pre-existing check at the end converts null to an empty object.
Comment 1 Curtis Windatt CLA 2010-12-01 16:06:29 EST
Jeff, is this something that will be integrated into bug 331068?
Comment 2 Jeff McAffer CLA 2010-12-01 16:17:56 EST
yes, this fix is included in the patch with bug 331068.
Comment 3 Curtis Windatt CLA 2010-12-02 14:43:34 EST
Fixed with bug 331068