Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[p2-dev] NPE in ProfileChangeRequest

It appears there is a NPE bug in ProfileChangeRequest#toString

If you don't have either additions or removals, the toString will
throw a NPE when iterating over the elements.  The underlying
variables (iusToRemove, iusToAdd) are lazily instantiated.  So if you
never create an addition or removal, they will be null when you
perform the toString.

public String toString() {
		StringBuffer result = new StringBuffer(1000);
		result.append("==Profile change request for "); //$NON-NLS-1$
		result.append(profile.getProfileId());
		result.append('\n');
		result.append("==Additions=="); //$NON-NLS-1$
		result.append('\n');
		for (IInstallableUnit iu : iusToAdd) { // blows up if no additions
have been made, need to wrap in null check
			result.append('\t');
			result.append(iu);
			result.append('\n');
		}
		result.append("==Removals=="); //$NON-NLS-1$
		result.append('\n');
		for (IInstallableUnit iu : iusToRemove) { // blows up if no removals
have been made, need to wrap in null check
			result.append('\t');
			result.append(iu);
			result.append('\n');
		}
		return result.toString();
	}


Back to the top