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

Bug 369598

Summary: NPE when expanding comments in the task editor
Product: z_Archived Reporter: David Green <greensopinion>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 3.7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description David Green CLA 2012-01-24 16:00:09 EST
when opening bug 325795, I occasionally see the following NPE and the editor becomes blank after pressing the '+' on the comments part.

I'm bootstrapped off of Mylyn master.

To reproduce:
# open bug 325795 in the task editor
# press the '+' button on the comments section
# observe that the editor goes blank and the NPE shows up in the error log

the only known workaround is to open the bug in the web browser

java.lang.NullPointerException
	at org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor$3.computeSize(RichTextEditor.java:267)
	at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:233)
	at org.eclipse.mylyn.internal.tasks.ui.editors.FillWidthLayout.computeSize(FillWidthLayout.java:169)
	at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:233)
	at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:35)
	at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:390)
	at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumHeight(SizeCache.java:477)
	at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:200)
	at org.eclipse.ui.forms.widgets.ExpandableComposite$ExpandableLayout.computeSize(ExpandableComposite.java:478)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.computeSize(ExpandableComposite.java:954)
	at org.eclipse.swt.layout.GridData.computeSize(GridData.java:491)
	at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:218)
	at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:163)
	at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:233)
	at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:35)
	at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:390)
	at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:429)
	at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
	at org.eclipse.ui.forms.widgets.ExpandableComposite$ExpandableLayout.computeSize(ExpandableComposite.java:478)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.computeSize(ExpandableComposite.java:954)
	at org.eclipse.swt.layout.GridData.computeSize(GridData.java:491)
	at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:218)
	at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:163)
	at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:233)
	at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:35)
	at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:390)
	at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:429)
	at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
	at org.eclipse.ui.forms.widgets.ExpandableComposite$ExpandableLayout.computeSize(ExpandableComposite.java:478)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.computeSize(ExpandableComposite.java:954)
	at org.eclipse.swt.layout.GridData.computeSize(GridData.java:491)
	at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:218)
	at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:163)
	at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:233)
	at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:35)
	at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:390)
	at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:429)
	at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
	at org.eclipse.ui.forms.widgets.Form$FormLayout.computeSize(Form.java:140)
	at org.eclipse.ui.forms.widgets.Form$FormLayout.computeMinimumWidth(Form.java:110)
	at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:422)
	at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
	at org.eclipse.ui.forms.widgets.SharedScrolledComposite.reflow(SharedScrolledComposite.java:194)
	at org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage.reflow(AbstractTaskEditorPage.java:1368)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart.expandAllComments(TaskEditorCommentPart.java:719)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart.access$12(TaskEditorCommentPart.java:692)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$5.run(TaskEditorCommentPart.java:754)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
Comment 1 Steffen Pingel CLA 2012-01-24 18:41:50 EST
That sounds like Eclipse maybe running out of handles in that case. Are you getting any other errors in the log when that happens? Are you able to continue to use the Eclipse instance after closing the editor?
Comment 2 David Green CLA 2012-01-24 19:11:59 EST
I'm not experiencing any other noticable problems; handles seem fine, and I'm able to use Eclipse just fine after closing the editor.

I'm experiencing this other stack trace immediately _before_ the NPE:

!ENTRY org.eclipse.text 4 2 2012-01-24 11:06:30.684
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.text".
!STACK 0
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeLo(Unknown Source)
	at java.util.TimSort.mergeAt(Unknown Source)
	at java.util.TimSort.mergeCollapse(Unknown Source)
	at java.util.TimSort.sort(Unknown Source)
	at java.util.TimSort.sort(Unknown Source)
	at java.util.Arrays.sort(Unknown Source)
	at java.util.Collections.sort(Unknown Source)
	at org.eclipse.mylyn.internal.tasks.ui.editors.AbstractHyperlinkTextPresentationManager.computeStyleRanges(AbstractHyperlinkTextPresentationManager.java:94)
	at org.eclipse.mylyn.internal.tasks.ui.editors.AbstractHyperlinkTextPresentationManager$Support.applyTextPresentation(AbstractHyperlinkTextPresentationManager.java:59)
	at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4877)
	at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionCollection(PresentationReconciler.java:579)
	at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage(PresentationReconciler.java:568)
	at org.eclipse.jface.text.presentation.PresentationReconciler.access$3(PresentationReconciler.java:564)
	at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.textChanged(PresentationReconciler.java:225)
	at org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2824)
	at org.eclipse.jface.text.TextViewer$VisibleDocumentListener.documentChanged(TextViewer.java:403)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:769)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:736)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:721)
	at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:796)
	at org.eclipse.jface.text.AbstractDocument.set(AbstractDocument.java:1237)
	at org.eclipse.jface.text.AbstractDocument.set(AbstractDocument.java:1217)
	at org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer.setDocument(MarkupViewer.java:99)
	at org.eclipse.jface.text.source.SourceViewer.setDocument(SourceViewer.java:574)
	at org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor.updateDocument(RichTextEditor.java:230)
	at org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor.configure(RichTextEditor.java:194)
	at org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor.createControl(RichTextEditor.java:295)
	at org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor.createControl(RichTextAttributeEditor.java:87)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$CommentViewer.expandComment(TaskEditorCommentPart.java:439)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$CommentViewer.access$0(TaskEditorCommentPart.java:430)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$CommentViewer$1.expansionStateChanged(TaskEditorCommentPart.java:336)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.fireExpanding(ExpandableComposite.java:1081)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.toggleState(ExpandableComposite.java:1065)
	at org.eclipse.ui.forms.widgets.ExpandableComposite.programmaticToggleState(ExpandableComposite.java:1115)
	at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.mylyn.commons.workbench.forms.CommonFormUtil.setExpanded(CommonFormUtil.java:69)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$CommentViewer.setExpanded(TaskEditorCommentPart.java:468)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$CommentGroupViewer.setFullyExpanded(TaskEditorCommentPart.java:245)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart.expandAllComments(TaskEditorCommentPart.java:709)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart.access$12(TaskEditorCommentPart.java:692)
	at org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart$5.run(TaskEditorCommentPart.java:754)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
Comment 3 David Green CLA 2012-01-24 20:21:35 EST
In case it helps, the problem occurs when expanding "comment 119":https://bugs.eclipse.org/bugs/show_bug.cgi?id=325795#c119
Comment 4 Steffen Pingel CLA 2012-01-25 06:38:36 EST
I can't reproduce the problem on Gtk with bug 325795 comment 119 but looking at RegionComparator there is definitely a problem. This simple test fails since compare() returns 1:

		Region r1 = new Region(0, 10);
		Region r2 = new Region(0, 10);
		assertEquals(r1, r2);
		assertEquals(0, new RegionComparator().compare(r1, r2));

I'll look into changing that.
Comment 5 Steffen Pingel CLA 2012-01-25 06:52:57 EST
I have pushed a fix and test for the comparator. Please check if that makes a difference and reopen if you are still experiencing the problem.
Comment 6 Steffen Pingel CLA 2012-01-25 06:52:59 EST
Created attachment 210044 [details]
mylyn/context/zip