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

Bug 319923

Summary: NPE in DefaultXMLPartitionFormatter
Product: [WebTools] WTP Source Editing Reporter: Valentin Baciu <valentinbaciu>
Component: wst.xmlAssignee: Rakesh <rakes123>
Status: VERIFIED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: keith.chong.ca, nsand.dev, rakes123
Version: 3.2Flags: nsand.dev: review+
Target Milestone: 3.2.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Full stack trace
none
patcha nsand.dev: iplog+

Description Valentin Baciu CLA 2010-07-14 17:19:39 EDT
Created attachment 174352 [details]
Full stack trace

I've hit this NPE when executing the follow XML schema editing scenario:
- create a new XML schema file with the New XML Schema wizard
- go to the graphical view
- select the elements compartment in the top level index figure
- right click and add a new element
- click away from the direct edit box to finish adding 
- select the element
- right click and choose remove from the context menu
- go to the source view
- the cursor should be right before the schema element's opening tag angle bracket
- hit Ctrl+Shift+F to format the document
- note the NPE

Here's part of the stack trace (see attachment for the full trace):

java.lang.NullPointerException
at org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter.formatStartTag(DefaultXMLPartitionFormatter.java:552)
at org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter.formatRegion(DefaultXMLPartitionFormatter.java:438)
at org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter.formatSiblings(DefaultXMLPartitionFormatter.java:481)
at org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter.format(DefaultXMLPartitionFormatter.java:204)
at org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter.format(DefaultXMLPartitionFormatter.java:160)
at org.eclipse.wst.xml.ui.internal.XMLFormattingStrategy.format(XMLFormattingStrategy.java:61)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193)
at org.eclipse.wst.sse.ui.StructuredTextMultiPassContentFormatter.formatMaster(StructuredTextMultiPassContentFormatter.java:56)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:142)
at org.eclipse.wst.sse.ui.internal.StructuredTextViewer.doOperation(StructuredTextViewer.java:515)
at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)

...
Comment 1 Rakesh CLA 2010-07-22 10:17:59 EDT
Created attachment 174980 [details]
patcha

A simple null pointer check seems to solve the issue.
Comment 2 Nick Sandonato CLA 2010-07-28 15:54:12 EDT
Patch looks good to me. Thanks.
Comment 3 Nick Sandonato CLA 2010-08-16 16:18:40 EDT
Fixed in Maintenance and HEAD.
Comment 4 Valentin Baciu CLA 2010-08-20 14:46:31 EDT
Verified with M-3.2.2-20100820035731 and I-3.3.0-20100820155725.