This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194939 - StringIndexOutOfBoundsException when declaring wicket namespace
Summary: StringIndexOutOfBoundsException when declaring wicket namespace
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 7.0
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-01 09:59 UTC by bht
Modified: 2011-03-28 09:03 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Page to copy from (478 bytes, text/html)
2011-02-01 09:59 UTC, bht
Details
Page to copy to (1.70 KB, text/html)
2011-02-01 10:00 UTC, bht
Details
Testcase (2.83 KB, text/html)
2011-03-09 06:13 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bht 2011-02-01 09:59:54 UTC
Created attachment 105538 [details]
Page to copy from

My aim is to fix a syntax error by replacting doctype and html tag. When I do so, then there is an exception in the log.

How to reproduce:
In the editor, open ToPage.html and FromPage.html.
Copy the 7 first lines from FromPage.html by highlighting in column 1 down to line 8 and pressing [Ctrl+C] (copy).
Switch to ToPage.html.
Highlight the first 3 lines by selecting in column 1 down to line 4 and press [Ctrl+V] (paste).
There is an error on line 1 now: Internal Error: Oops That was not supposed to happen ...

From log:



INFO [org.netbeans.modules.html.validation.ValidationTransaction]: An internal error occured during validation of file:/C:/bt/java/netbeans/bugs/_new/DocTypeChange/ToPage.html
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.StringBuffer.charAt(StringBuffer.java:162)
	at com.thaiopensource.validate.schematron.OutputHandler.startElement(Unknown Source)
	at net.sf.saxon.event.ContentHandlerProxy.startContent(ContentHandlerProxy.java:362)
	at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:197)
	at net.sf.saxon.event.ComplexContentOutputter.startContent(ComplexContentOutputter.java:550)
	at net.sf.saxon.event.ComplexContentOutputter.characters(ComplexContentOutputter.java:157)
	at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:245)
	at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
	at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)
	at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)
	at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
	at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)
	at net.sf.saxon.instruct.Choose.processLeavingTail(Choose.java:686)
	at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)
	at net.sf.saxon.instruct.Template.expand(Template.java:220)
	at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257)
	at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281)
	at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)
	at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)
	at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)
	at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)
	at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)
	at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)
	at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)
	at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:212)
	at net.sf.saxon.instruct.ApplyTemplates.process(ApplyTemplates.java:170)
	at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)
	at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)
	at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)
	at net.sf.saxon.Controller.transformDocument(Controller.java:1807)
	at net.sf.saxon.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:144)
	at com.thaiopensource.xml.sax.ForkContentHandler.endDocument(Unknown Source)
	at com.thaiopensource.xml.sax.ForkContentHandler.endDocument(Unknown Source)
	at org.netbeans.modules.html.validation.patched.RootNamespaceSniffer.endDocument(RootNamespaceSniffer.java:54)
	at nu.validator.xml.AttributesPermutingXMLReaderWrapper.endDocument(AttributesPermutingXMLReaderWrapper.java:158)
	at nu.validator.xml.NamespaceDroppingXMLReaderWrapper.endDocument(NamespaceDroppingXMLReaderWrapper.java:220)
	at nu.validator.xml.CombineContentHandler.endDocument(CombineContentHandler.java:64)
	at org.xml.sax.helpers.XMLFilterImpl.endDocument(XMLFilterImpl.java:473)
	at nu.validator.xml.IdFilter.endDocument(IdFilter.java:177)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidator.java:950)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:516)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:333)
	at nu.validator.xml.WiretapXMLReaderWrapper.parse(WiretapXMLReaderWrapper.java:152)
	at nu.validator.xml.NamespaceDroppingXMLReaderWrapper.parse(NamespaceDroppingXMLReaderWrapper.java:325)
	at nu.validator.xml.AttributesPermutingXMLReaderWrapper.parse(AttributesPermutingXMLReaderWrapper.java:285)
[catch] at org.netbeans.modules.html.validation.ValidationTransaction.validate(ValidationTransaction.java:642)
	at org.netbeans.modules.html.validation.ValidationTransaction.validateCode(ValidationTransaction.java:498)
	at org.netbeans.modules.html.validation.ValidatorImpl.validate(ValidatorImpl.java:101)
	at org.netbeans.modules.html.editor.api.gsf.HtmlParserResult.getValidationResults(HtmlParserResult.java:240)
	at org.netbeans.modules.html.editor.api.gsf.HtmlParserResult.getDiagnostics(HtmlParserResult.java:217)
	at org.netbeans.modules.csl.editor.fold.GsfFoldManager.hasErrors(GsfFoldManager.java:751)
	at org.netbeans.modules.csl.editor.fold.GsfFoldManager.access$000(GsfFoldManager.java:107)
	at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.run(GsfFoldManager.java:351)
	at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.run(GsfFoldManager.java:302)
	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:676)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Comment 1 bht 2011-02-01 10:00:54 UTC
Created attachment 105539 [details]
Page to copy to
Comment 2 Marek Fukala 2011-02-02 16:03:22 UTC
caused by the wicket namespace declaration.
Comment 3 Marek Fukala 2011-02-03 12:09:13 UTC
another example to reproduce the  SIOOB is the ${nb_repo_home}/openide.util.lookup/src/org/openide/util/lookup/doc-files/index.html reported in the issue 192713

It is an internal validator error occurring even in the latest validator.nu version.
Comment 4 bht 2011-02-12 23:15:32 UTC
Is there a chance raise priority to 2?

As a wicket developer, I depend on the validator in the editor, which is so quite broken (works in 9.1).

I would love to keep using the daily builds for testing and bug reporting :)
Comment 5 Marek Fukala 2011-02-14 10:52:48 UTC
What exactly is *broken*? Except the annotation at the beginning of the file there is no user impact of that issue. Of course except the file not being validated ;-) BTW the exception neither pops un in the editor nor is logged with INFO level.
Comment 6 bht 2011-02-14 17:39:45 UTC
Subsequent validation breaks. The editor does not allow me to collapse elements and so on. Quite a lot is broken actually.
Comment 7 bht 2011-02-15 07:53:42 UTC
Please consider that I reported another bug (now fixed) that appears to have prevented this from showing. Are you sure that there is not a third validation bug that shows only after this is fixed?
Comment 8 Marek Fukala 2011-02-15 11:28:23 UTC
What do you mean by prevented from showing? Do you mean that the issue is not occurring at all or just not popping up in the exception dialog and being logged? 

I suppose you mean this one: Bug 194618 - Error parsing simple valid HTML.

These two are unrelated.

I've recently modified the logging of the validator issues so the known exceptions like this one are logged just in FINE level so in fact they are not presented to the user at all. However this doesn't mean the issue is not there.
Comment 9 bht 2011-02-15 17:11:58 UTC
What I mean by that is that even though unrelated, the other issue prevented this from occuring.

That may not necessarily be reflected in the testcase, but in my production files. If that is the case then it may just take too long to get the parser fully tested and fixed in time. Therefore, and because of the fact that this error did not appear in 6.9, I am suggesting to raise the priority.

I noticed that the error handling was changed and I appreciate this. But it does not seem to change the behavior of the parser.
Comment 10 bht 2011-02-24 08:29:05 UTC
I am raising the priority to 2 because I think that priority 2 ensures that NetBeans will not be released with this bug included.
Comment 11 Marek Fukala 2011-03-04 12:24:13 UTC
Please let me summarize the state of this issue:
1) there is a bug in the html validator causing the html code validation doesn't work *fully* for some pages. Even if the problem occurs there are some errors reported for the page.
2) apart from the above the user consequence is that the file is marked as errorneous - an error annotation is shown at the very first line saying "internal error occurred ..."
3) the validation problem has *absolutely no influence* to any other editor functionality. No feature is built on top of it. So code completion, coloring, indentation etc. does work normally.
4) I noticed that there are no folds for the page - that is different P3 issue.

My solution for now is:
#1 - investigate why the problem in the validator happens and possibly report it to Henri Sivonen who is the author of the validator. I doesn't seem to be fixable within 7.0 timeframe

#2 - I'll change the annotation type so the file "correctness" status won't be "error" but unchanged by this issue

#4 - I've filled a P3 Bug 196292 - No code folds for some specific files

With respect to the above I do not agree with this issue being P2. In my opinion the consequence is minimal and it is not a regression from 6.9. I'm going to fix the #2 now...
Comment 12 Marek Fukala 2011-03-04 13:00:13 UTC
#2 (status of the file w/ the internal error) fixed in web-main#33ace80778fa
Comment 13 Marek Fukala 2011-03-04 13:12:47 UTC
Actually I was wrong about the #3 - there is a connection. Since the validator adds its errors to the html parser results there may be a consequences in the editor features. And that was exactly the case of folding - I didn't know there's something like if(errors_in_code) { do_not_show_folds; } in the GsfFoldManager. Since I've changes the error type for the internal error just to INFO level, the folds are back now.
Comment 14 Marek Fukala 2011-03-04 13:17:38 UTC
The code completion behavior used to be affected by the internal error as well since it triggered some fallback code active if the parse tree is broken.

BHT, can you please verify the behavior after the fix and verify it helps?? Please use the build with the fix which is going to be put here by the building process. Thanks in advance and let me apologize a bit!
Comment 15 Quality Engineering 2011-03-08 05:45:21 UTC
Integrated into 'main-golden', will be available in build *201103080000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/33ace80778fa
User: Marek Fukala <mfukala@netbeans.org>
Log: #194939 - StringIndexOutOfBoundsException when declaring wicket namespace
Comment 16 bht 2011-03-09 06:13:02 UTC
Created attachment 106839 [details]
Testcase
Comment 17 bht 2011-03-09 06:15:19 UTC
Marek,
Thanks very much for addressing the issue. I have attached a test file that may show the problem a little better. It works fine in NetBeans 6.9.
Comment 18 bht 2011-03-13 07:34:39 UTC
May be My comments were confusing.

It still does not work.
Comment 19 Marek Fukala 2011-03-14 13:49:26 UTC
As for the folding, you are right, there are other ERRORs in the file causing the folding to be disabled. I do not why but it seemed to me it works well after the change I did before. 

If you take a build with the fix of Bug 196632 - Unknown attribute breaks other editor functionality you should be able to get the folds. The issue makes all the html validator problems warnings only and hence the folding state is unaffected.

I'm sorry for the confusion.

BTW any other problems apart from the folding? There shouldn't be any. If they are please specify exactly what and where doesn't work and how can I reproduce. Please use steps like 1) open file xxx, 2) put caret to 10:5, 3) do something else => something doesn't work. Thanks for your understanding.
Comment 20 bht 2011-03-26 07:55:59 UTC
I have had some more time working with the fixed build.

As a consequence of the fix, some HTML errors, possibly due to the name-spaced tags are now no longer flagged as errors but as warnings.

For example, if you try in the attachment "Testcase":
            <tr wicket:id="idRow">
                <th colspan="2">ID:</td>
                <td colspan="2" wicket:id="id">12356</td>
            </tr>

(the first <th> is unmatched (incorrectly matched by </td>)

then there is a yellow warning icon not a red one as in version 9.1.

I think we need the error flagging for the real HTML errors otherwise one cannot see that the file is invalid as a whole.

I found this when I missed a </html> tag and the file was still valid.

You can try this with the testcase and there is no red icon as a conseequence.
Comment 21 bht 2011-03-26 08:14:07 UTC
I don't know whether this name space filtering is the final solution. Not name spaced content enclosed by name space filtered tags is hidden, which means in case of the testcase, the content within the <head> section is missing, therefore causing warnings and the lack of proper validation.

I don't know how NB6.9 does it, but I could imagine that name spaced tags are kept in a separate space so that they don't interfere with others but still are validated for nesting, closing etc..
Comment 22 Marian Mirilovic 2011-03-28 08:19:13 UTC
Needs to be resolved or waived for NB 7.0
Comment 23 Marek Fukala 2011-03-28 09:03:24 UTC
The original issue has been already fixed. The latest user complain has been filed as new issues:

Bug 197144 - Namespaces filtering problem
Bug 197145 - Html validator doesn't flag a file as erroneous 

bht, file the problems as new issues since this way we cannot track them properly.