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

Bug 130606

Summary: Malformed JSP page locks up JSP Translator / Parser
Product: [WebTools] WTP Source Editing Reporter: Patric Rufflar <patric>
Component: jst.jspAssignee: Nitin Dahyabhai <thatnitind>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david_williams, for.work.things, itewksbu, nsand.dev, patric
Version: 1.0.1Keywords: helpwanted
Target Milestone: Future   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Create a new dynamic web project and put this file into your WebContent directory and build the project
none
Another performance/parsing problem. Just copy the file to your WebContent
none
Parsing bug with not correctly closed attributes. Just copy the file to your WebContent directory none

Description Patric Rufflar CLA 2006-03-06 13:58:49 EST
Hello,

A special malformed JSP locks up the JSP Translator/Parser (translation process takes at least several minutes).

The problems seem to caused by not correctly closed html tags and followed by many jsp scriptlets.

We have a big project with a huge amount of jsp files, some are not malformed. Webtools cannot compile it and got stuck on some files. In my opinion this is a blocker because we cannot use WTP at the moment.

The error occurs on a fresh installation of WTP 1.0.1 (all in one bundle). Just create a Dynamic Web Project and a JSP file in the WebContent folder and paste the following not-really-minimal example to the file and start the build process.
The CPU-consumption goes up to 100%, canceling the build process is not possible. You have to kill the JVM.

I would be really glad if this will be fixed soon.

Btw: The content assist (suggest closing of tags) was enabled. I could not manage to disable it. Disabling this feature in the preferences seems not to work.

Best Regards,
Patric

<html>
<body>
<%
if(true)
{
%>
            <input

            <input 
<%
}
%>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>
<%
if(true)
{
%>
            <input

            <input 
<%
}
%>                                      
<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>

<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>

<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>

<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>
<%
if(true)
{
%>
            <input

            <input 
<%
}
%>

<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


<TABLE>
<TR>
<TD>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>

<%=out %><%=out %><%=out %><%=out %><%=out %><%=out %>
</TD>
</TR>
</TABLE>


</body>
</html>
Comment 1 Patric Rufflar CLA 2006-03-06 14:00:44 EST
Created attachment 35781 [details]
Create a new dynamic web project and put this file into your WebContent directory and build the project
Comment 2 David Williams CLA 2006-03-06 14:06:05 EST
I'm targeted to 1.0.2, assuming we can easily reproduce. 

Phil, please take a look and see if can narrow down. 

Amy, can you please check out the "preference" statement, and see if a new bug should be open for it? 


thanks for reporting. 
Comment 3 Amy Wu CLA 2006-03-06 17:22:57 EST
> Btw: The content assist (suggest closing of tags) was enabled. I could not
> manage to disable it. Disabling this feature in the preferences seems not to
> work.

I don't believe we have this preference.  Where are you setting this preference?
Comment 4 Patric Rufflar CLA 2006-03-06 17:34:35 EST
Amy:
I unchecked "Automatically make suggestions"  at the page Window->Preferences->Web and XML->HTML Files->HTML Source

Comment 5 Amy Wu CLA 2006-03-07 13:05:10 EST
Thanks for the clarification.  I see the bug now, and I opened a separate new bug for the auto-propose content assist preference issue: bug 130762.

Please CC yourself to that bug to track it.  The severity is currently "normal" and it is not targetted to fix for 1.0.2 at the moment.  Please let me know if you feel differently.  Thanks.
Comment 6 Phillip Avery CLA 2006-03-07 13:38:16 EST
I can definitely reproduce on wtp-sdk-M-M200603070318-200603070318.zip.

I'll have to look in the debugger today after smoktesting.
Comment 7 Phillip Avery CLA 2006-03-07 16:44:08 EST
This is a good testcase, as it exposes a bunch of problems w/ JSPTranslator/JSPTranslation concurrency.


One issue is the "isUseBeanTag()" is causing another performance problem here i think.

JSPTranslator is still iterating ALL of the regions, even after knowing the "TAG_NAME" region isn't usebean.

The logic should just break after encountering "TAG_NAME" region no matter what, 
whether it's useBean or not.



Another issue is synchronization, while creating a compilation unit, another thread is trying to access it.
Seems like we might need to synch the creation as well?

thread 1

org.eclipse.jdt.internal.core.util.CommentRecorderScanner(org.eclipse.jdt.internal.compiler.parser.Scanner).getNextToken() line: 950
org.eclipse.jdt.internal.compiler.SourceElementParser(org.eclipse.jdt.internal.compiler.parser.Parser).parse() line: 8837
org.eclipse.jdt.internal.compiler.SourceElementParser(org.eclipse.jdt.internal.compiler.parser.Parser).parse(org.eclipse.jdt.internal.compiler.env.ICompilationUnit, org.eclipse.jdt.internal.compiler.CompilationResult, int, int) line: 9071
org.eclipse.jdt.internal.compiler.SourceElementParser(org.eclipse.jdt.internal.compiler.parser.Parser).parse(org.eclipse.jdt.internal.compiler.env.ICompilationUnit, org.eclipse.jdt.internal.compiler.CompilationResult) line: 9036
org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit, boolean) line: 1415
org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(org.eclipse.jdt.internal.core.OpenableElementInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource) line: 132
org.eclipse.jdt.internal.core.CompilationUnit(org.eclipse.jdt.internal.core.Openable).generateInfos(java.lang.Object, java.util.HashMap, org.eclipse.core.runtime.IProgressMonitor) line: 229
org.eclipse.jdt.internal.core.CompilationUnit(org.eclipse.jdt.internal.core.JavaElement).openWhenClosed(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) line: 503
org.eclipse.jdt.internal.core.BecomeWorkingCopyOperation.executeOperation() line: 38
org.eclipse.jdt.internal.core.BecomeWorkingCopyOperation(org.eclipse.jdt.internal.core.JavaModelOperation).run(org.eclipse.core.runtime.IProgressMonitor) line: 720
org.eclipse.jdt.internal.core.BecomeWorkingCopyOperation(org.eclipse.jdt.internal.core.JavaModelOperation).runOperation(org.eclipse.core.runtime.IProgressMonitor) line: 779
org.eclipse.jdt.internal.core.CompilationUnit.getWorkingCopy(org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.jdt.core.IProblemRequestor, org.eclipse.core.runtime.IProgressMonitor) line: 884
org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension(org.eclipse.jst.jsp.core.internal.java.JSPTranslation).createCompilationUnit() line: 458
org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension(org.eclipse.jst.jsp.core.internal.java.JSPTranslation).getCompilationUnit() line: 340
org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension(org.eclipse.jst.jsp.core.internal.java.JSPTranslation).setProblemCollectingActive(boolean) line: 520
org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator.validateFile(org.eclipse.core.resources.IFile, org.eclipse.wst.validation.internal.provisional.core.IReporter) line: 48
org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPValidator).validate(org.eclipse.wst.validation.internal.provisional.core.IValidationContext, org.eclipse.wst.validation.internal.provisional.core.IReporter) line: 149
org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.validate() line: 277
org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator.reconcileModel(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion) line: 243
org.eclipse.wst.sse.ui.internal.reconcile.validator.ReconcileStepForValidator(org.eclipse.jface.text.reconciler.AbstractReconcileStep).reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion) line: 96
org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy.reconcile(org.eclipse.jface.text.ITypedRegion, org.eclipse.jface.text.reconciler.DirtyRegion) line: 185
org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor(org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor).process(org.eclipse.jface.text.reconciler.DirtyRegion) line: 141
org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(org.eclipse.jface.text.reconciler.DirtyRegion) line: 196
org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor(org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor).run(org.eclipse.core.runtime.IProgressMonitor) line: 534
org.eclipse.core.internal.jobs.Worker.run() line: 58


thread 2

org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension(org.eclipse.jst.jsp.core.internal.java.JSPTranslation).getCompilationUnit() line: 339
org.eclipse.jst.jsp.ui.internal.contentassist.JSPCompletionProcessor.computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) line: 93
org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaContentAssistProcessor.computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) line: 70



Also many times it seems like in many cases many different processors are "competing" for JSPTranslation, sometimes on the UI thread.

	- hyperlink
	- hover
	- content assist
	- as you type validation
	- etc...


I don't think it's ALL JSP translation stuff though because I can produce NPE like this:
If I type away at the beginning of the document.

!ENTRY org.eclipse.ui 4 0 2006-03-07 16:38:20.009
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.RuntimeException: java.lang.NullPointerException
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:113)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2331)
	at org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter.replaceTextRange(StructuredDocumentToTextAdapter.java:1187)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5755)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6466)
	at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2086)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5039)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5065)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4804)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:949)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:934)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:962)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:958)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1272)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3336)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3236)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3965)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1799)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2905)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1899)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1863)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:417)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:99)
	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:374)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.NullPointerException
	at org.eclipse.jface.text.DefaultPositionUpdater.update(DefaultPositionUpdater.java:227)
	at org.eclipse.wst.sse.core.internal.text.GenericPositionManager.updatePositions(GenericPositionManager.java:395)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.updateDocumentData(BasicStructuredDocument.java:2602)
	at org.eclipse.jst.jsp.core.internal.parser.JSPReParser.reparse(JSPReParser.java:141)
	at org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser.reparse(StructuredDocumentReParser.java:1284)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.updateModel(BasicStructuredDocument.java:2614)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1867)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2335)
	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)

I'll look some more.  We had a similar problem w/ having an unclosed tag before, not sure if this is the same.
Comment 8 Phillip Avery CLA 2006-03-08 12:43:45 EST
I think I found the major performance problem.

checkAllAttributeValueContainers() has a logic problem causing exponential extra looping, it goes through ALL embedded regions again for each embedded region.

In your testcase I think it's around 1150 embedded regions, so the bug causes 1150x1150 (1322500) extra cycles!

One simple way to fix it is break after the first time you iterate the embedded region container.  Fixing logic in this area seems to make the editor usable again.
Comment 9 Phillip Avery CLA 2006-03-08 18:15:01 EST
OK I just dropped this fix to 1.5 and 1.0.2.
Please verify if you get a chance (next build).
Thanks!
Comment 10 Patric Rufflar CLA 2006-03-09 07:28:56 EST
Thank you for your quick fix.
I played around with the nightly build (wtp-M-M200603090344-200603090344.zip) and I think you eliminated one bug in the jsp parsing/translation, but there are still some problems left. 

One of them is the thread synchronisation problem you posted two days ago.

But there are another bugs in the jsp parser left.
Please have a look at the two newly attached files. One file shows another performance problem, the second one shows a parsing problem.

One issue is caused by not closed attributes. Maybe you should stop parsing attributes at the end of a line or when some special characters occur (for example: < >    et cetera. I think those are not allowed inside attributes. But we should consult the xml/html specification)

I experienced two times another exception in the error_log but I could not reproduce it. But it has something to do with undo/redo on truncated files.
It seems that the text editor tries to restore some positions which do not exist anymore:

org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: 
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:189)
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:174)
	at org.eclipse.jface.text.Position.<init>(Position.java:60)
	at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.getNodeCoverage(StructuredRegionProcessor.java:102)
	at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:76)
	at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:62)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:375)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)



I hope it is ok for you to reopen this bug.
Thank you for looking at these problems.

Comment 11 Patric Rufflar CLA 2006-03-09 07:33:53 EST
Created attachment 35976 [details]
Another performance/parsing problem. Just copy the file to your WebContent
Comment 12 Patric Rufflar CLA 2006-03-09 07:34:58 EST
Created attachment 35978 [details]
Parsing bug with not correctly closed attributes. Just copy the file to your WebContent directory
Comment 13 Phillip Avery CLA 2006-03-09 13:17:09 EST
In the XML editor, we do stop parsing when we hit an illegal attribute value character such as '<'.  In basic JSP, we can't do that because I believe those characters are allowed.

The fact that the comment isn't being parsed as a comment does seem like another bug though:

 <COL width="180>
 </COLGROUP>
 <%-- this is only a comment. But WTP shows here an error. for if case class --%>

We should add this to our test bucket.

As for the performance problem, I believe it's due to the rendering of many annotations on the same line.  If I split the annotations to separate lines, the editor performs much better. I think there might be something slow in the base logic for this.

We may be able to improve this by imposing limits such as:
 - how many overall annotations to show
 - how many annotations to allow on the same line
 - limit annotation length

It would also be good if I could produce a testcase for the base for the multiple annotations on one line issue, and open a base bug.

It seems like this is more of an especially bad performing case than a blocking bug.
Comment 14 David Williams CLA 2006-03-17 03:12:31 EST
As Phil remarked, I think the "blocking" part of this defects if fixed. Let me know if you disagree. 

Nitin, one of us should check out this detail. 



Comment 15 David Williams CLA 2006-04-05 00:23:00 EDT
As noted, we think we have the worst of this bug fixed, but will leave open for now ... I believe Nitin is still investigating some issues for possibly fixing in 1.5. 
Comment 16 Patric Rufflar CLA 2006-05-31 17:14:34 EDT
Hello everyone,

this bug seems to be still there in WTP RC2 (and supposably in newer build, too).
After the first fix (targeted at 1.0.2) from Philipp the editor is usable again (no 100% CPU anymore) but the validation is still useless.

Is it possible to investigate on this issue for 1.5?

Thank you!
Best Regards,
Patric Rufflar
Comment 17 Nitin Dahyabhai CLA 2006-05-31 17:23:27 EDT
Patric, can you remind of which validation problem is still there in RC4?

Also, withare so many different issues mentioned in this one bug, I'm having a great deal of difficulty determining which problem we're discussing.  If the original problem has been fixed, I'd rather close out this bug and have the remaining problems (such as the ones from comment 10 that may still exist) reopened individually against 1.5.
Comment 18 Patric Rufflar CLA 2006-05-31 20:34:02 EDT
Nitin,

I just tried WTP RC4.
Have a look at the following minimalistic example:
<input
<%
	 String a = "This code is correct";
%>

The uncorrect closed input tag caused the parser to mark every line as an error, because it is treating the following lines as a HTML section.
I have the following suggestions to improve parsing:
* Stop parsing html tags after <% is reached. Start parsing JSP section.
* When an unclosed tag reaches another < not inside a "" or a '' parsing of this html tag should be stopped, because another one seems to start. 

There are major problems with your parser, espacially with HTML parsing. To follow your suggestions, I opened bug 144807 , bug 144809 , bug 144810 , bug 144812 .

I saw some other stack traces as well during my parser tests, but i could not reproduce all. Nevertheless I will paste some stacktraces here because I do not know a more suitable place for them:

org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: 
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:188)
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:173)
	at org.eclipse.ui.internal.texteditor.quickdiff.compare.equivalence.DocEquivalenceComparator.<init>(DocEquivalenceComparator.java:47)
	at org.eclipse.ui.internal.texteditor.quickdiff.DocumentLineDiffer.handleChanged(DocumentLineDiffer.java:958)
	at org.eclipse.ui.internal.texteditor.quickdiff.DocumentLineDiffer.documentChanged(DocumentLineDiffer.java:801)
	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)



org.eclipse.emf.common.util.WrappedException: An exception was ignored during command execution
	at org.eclipse.emf.common.command.BasicCommandStack.handleError(BasicCommandStack.java:279)
	at org.eclipse.emf.common.command.BasicCommandStack.undo(BasicCommandStack.java:146)
	at org.eclipse.wst.sse.core.internal.undo.StructuredTextUndoManager.undo(StructuredTextUndoManager.java:608)
	at org.eclipse.wst.sse.ui.StructuredTextViewerUndoManager.undo(StructuredTextViewerUndoManager.java:183)
	at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3481)
	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:466)
	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)
Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException
	at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:113)
	at org.eclipse.wst.sse.core.internal.undo.StructuredTextCommandImpl.undo(StructuredTextCommandImpl.java:127)
	at org.eclipse.emf.common.command.BasicCommandStack.undo(BasicCommandStack.java:141)
	... 53 more
Caused by: java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at org.eclipse.jface.text.GapTextStore.moveAndResizeGap(GapTextStore.java:124)
	at org.eclipse.jface.text.GapTextStore.adjustGap(GapTextStore.java:70)
	at org.eclipse.jface.text.GapTextStore.replace(GapTextStore.java:196)
	at org.eclipse.wst.sse.core.internal.text.StructuredDocumentTextStore.replace(StructuredDocumentTextStore.java:168)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.updateDocumentData(BasicStructuredDocument.java:2635)
	at org.eclipse.jst.jsp.core.internal.parser.JSPReParser.reparse(JSPReParser.java:141)
	at org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser.reparse(StructuredDocumentReParser.java:1284)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.updateModel(BasicStructuredDocument.java:2657)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1899)
	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)
	... 55 more


java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.wst.sse.core.internal.undo.StructuredTextUndoManager$InternalStructuredDocumentListener.processStructuredDocumentEvent(StructuredTextUndoManager.java:75)
	at org.eclipse.wst.sse.core.internal.undo.StructuredTextUndoManager$InternalStructuredDocumentListener.processStructuredDocumentEvent(StructuredTextUndoManager.java:120)
	at org.eclipse.wst.sse.core.internal.undo.StructuredTextUndoManager$InternalStructuredDocumentListener.regionChanged(StructuredTextUndoManager.java:125)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireEvent(BasicStructuredDocument.java:525)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1164)
	at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1931)
	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.doBackspace(StyledText.java:2050)
	at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:5626)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5028)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5049)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4789)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
	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)


Best Regards,
Patric Rufflar
Comment 19 David Williams CLA 2006-06-01 13:52:20 EDT
no time this release, unless a case can be made this is blocking some usecase. 
Comment 20 Ian Tewksbury CLA 2010-01-20 14:47:07 EST
I tested the given file with 3.2 and it validated correctly in less then a second with no logged messages.  Safe to close now.
Comment 21 Nick Sandonato CLA 2010-04-26 16:54:41 EDT
I think the vast majority of problems have been cleaned up over the years. The performance issues are no longer apparent and validation has tightened up a bit.

I do not think the hypervalidation of the open attribute is incorrect since a lot of it's all technically valid to be in the attribute value. Maybe in the future we could guess where the appropriate point for the closing quote would be or just highlight the attribute name saying it's unclosed. But this certainly indicates that you've changed something drastically by leaving open the quote and it wasn't intended.