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

Bug 144810

Summary: JSP parser fails parsing erroneous jsp directives
Product: [WebTools] WTP Source Editing Reporter: Patric Rufflar <patric>
Component: jst.jspAssignee: Ian Tewksbury <itewksbu>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: major    
Priority: P2 CC: itewksbu, keith.treague, nsand.dev, patric
Version: 1.5Keywords: helpwanted
Target Milestone: 3.2 M2Flags: nsand.dev: review+
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Fix Patch nsand.dev: iplog+

Description Patric Rufflar CLA 2006-05-31 20:01:41 EDT
Hello everyone,

the following problem occours on the brand new WTP 1.5 RC4

1. create a new JSP file
2. paste the following:
<%@ 
<%= %>
%>

The following exception is thrown:
java.lang.NullPointerException
	at org.eclipse.wst.xml.core.internal.parser.ContextRegionContainer.getEndOffset(ContextRegionContainer.java:111)
	at org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner.internalGetPartition(StructuredTextPartitioner.java:560)
	at org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner.computePartitioning(StructuredTextPartitioner.java:112)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.computePartitioning(BasicStructuredDocument.java:1036)
	at org.eclipse.jface.text.TextUtilities.computePartitioning(TextUtilities.java:426)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.getPartitions(DirtyRegionProcessor.java:375)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor$DocumentListener.partitionsChanged(DirtyRegionProcessor.java:111)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor$DocumentListener.documentChanged(DirtyRegionProcessor.java:59)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireDocumentChanged(BasicStructuredDocument.java:443)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1185)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1946)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2367)
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.access$0(JobSafeStructuredDocument.java:1)
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument$1.run(JobSafeStructuredDocument.java:95)
	at org.eclipse.wst.sse.ui.EditorExecutionContext.execute(EditorExecutionContext.java:42)
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:105)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2363)
	at org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter.replaceTextRange(StructuredDocumentToTextAdapter.java:1187)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5738)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6447)
	at org.eclipse.swt.custom.StyledText.paste(StyledText.java:5786)
	at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3510)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:862)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1439)
	at org.eclipse.wst.sse.ui.internal.StructuredTextViewer.doOperation(StructuredTextViewer.java:361)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:461)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:424)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:466)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:799)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:846)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:564)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:506)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1923)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)

if you now save the file another exception is thrown:
java.lang.NullPointerException
	at org.eclipse.wst.xml.core.internal.parser.ContextRegionContainer.getEndOffset(ContextRegionContainer.java:111)
	at org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner.internalGetPartition(StructuredTextPartitioner.java:560)
	at org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner.computePartitioning(StructuredTextPartitioner.java:112)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.computePartitioning(BasicStructuredDocument.java:1036)
	at org.eclipse.jface.text.TextUtilities.computePartitioning(TextUtilities.java:426)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.computePartitioning(DirtyRegionProcessor.java:265)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.computePartitioning(DirtyRegionProcessor.java:246)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.process(DirtyRegionProcessor.java:478)
	at org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor.process(DocumentRegionProcessor.java:136)
	at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:196)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:534)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)


Best Regards,
Patric Rufflar
Comment 1 Nitin Dahyabhai CLA 2006-06-05 21:42:01 EDT
Increasing severity since we're losing/dropping user data here.  There's a "hole" in the structured document at the position that the partitioner is trying to access.
Comment 2 Nitin Dahyabhai CLA 2006-06-12 13:25:11 EDT
Changing severity back to the original "major" and lowering priority.  As an edge case, well keep looking at it but I'm not sure we'll have a fix in time for 1.5.
Comment 3 Ian Tewksbury CLA 2009-06-29 14:04:42 EDT
This is not occurring in WTP 3.2
Comment 4 Ian Tewksbury CLA 2009-06-29 14:59:33 EDT
(In reply to comment #3)
> This is not occurring in WTP 3.2
> 

Sorry, I meant it is not occurring in 3.1-20090616035105
Comment 5 Ian Tewksbury CLA 2009-08-18 08:31:10 EDT
My last test of this must have been mistaken this error is still being logged using 3.2I-20090818_003224, I will investigate further.
Comment 6 Ian Tewksbury CLA 2009-08-18 10:29:12 EDT
Created attachment 144827 [details]
Fix Patch

The issue here was that when the JSPSourceParser found an UNDEFINED region and the previous region was also UNDEFINED it would extend the previous UNDEFINED region to include the new UNDEFINED region, but if that previous region was a ITextRegionContainer it should also add the new region as a child region of the container and update the new regions start accordingly.  Because that was not being done the new appended UNDEFINED regions length was added to the container but not the region itself, so when the region at the extra length is requested it null pointers.

This patch adds in the necessary checks and updates to deal with this situation.
Comment 7 Nick Sandonato CLA 2009-09-01 16:13:08 EDT
The patch looks good to me.