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

Bug 356914

Summary: NPE when activating a task having another task open with same invisible context elements
Product: z_Archived Reporter: Jan Mauersberger <mauersberger>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: 3.7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Jan Mauersberger CLA 2011-09-07 07:12:12 EDT
Build Identifier: M20100909-0800

Well, I have no reproduction scenario yet but I can outline the code parts of MyLyn that are affected. The NPW stack:

java.lang.NullPointerException
	at org.eclipse.mylyn.internal.context.ui.editors.ContextWrapper.isForSameTaskAs(ContextWrapper.java:23)
	at org.eclipse.mylyn.internal.context.ui.editors.InvisibleContextElementsPart.isActiveTask(InvisibleContextElementsPart.java:320)
	at org.eclipse.mylyn.internal.context.ui.editors.InvisibleContextElementsPart.access$0(InvisibleContextElementsPart.java:317)
	at org.eclipse.mylyn.internal.context.ui.editors.InvisibleContextElementsPart$1.contextChanged(InvisibleContextElementsPart.java:124)

The code executed is

public boolean isForSameTaskAs(IInteractionContext context) {
	return context != null && context.getHandleIdentifier().equals(task.getHandleIdentifier());
}

where as the call to "context.getHandleIdentifier()" returns null. The context implementation class is a CompositeInteractionContext, thus the code is:

public String getHandleIdentifier() {
	if (contexts.values().size() == 1) {
		return contexts.keySet().iterator().next();
	} else {
		return null;
	}
}

In my case the contexts hashmap contains several keys, thus null is returned.

Reproducible: Always
Comment 1 Steffen Pingel CLA 2012-02-17 05:56:16 EST
Thanks for the bug report! I have committed a simple fix: http://review.mylyn.org/300. Shawn, please reopen if we need to make adjustments.
Comment 2 Steffen Pingel CLA 2012-02-17 05:56:19 EST
Created attachment 211167 [details]
mylyn/context/zip