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 139350

Summary: ArrayIndexOutOfBoundsException: 8
Product: editor Reporter: Petr Blaha <blaha>
Component: Formatting & IndentationAssignee: issues@editor <issues>
Status: VERIFIED FIXED    
Severity: blocker CC: gord, jsedek, mschovanek, natie, nicolo, pslechta, schnappi, sustaining, the_lucius
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=11928
Issue Type: DEFECT Exception Reporter: 11928
Attachments: sample file from project that generates AIOOBE on reformat
tested project
release61_fixes version of editor.indent with the fix. Backup the original file in ide9/modules and replace it with the new one.
Mercurial bundle with the fix.

Description Petr Blaha 2008-07-09 08:10:12 UTC
Following exception is thrown for HTML,JSP formatting:

java.lang.ArrayIndexOutOfBoundsException: 8
        at org.netbeans.modules.editor.indent.api.IndentUtils.cachedOrCreatedIndentString(IndentUtils.java:221)
        at org.netbeans.modules.editor.indent.api.IndentUtils.createIndentString(IndentUtils.java:194)
        at org.netbeans.modules.editor.indent.spi.Context.modifyIndent(Context.java:177)
        at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.reformat(TagBasedLexerFormatter.java:358)
        at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.reformat(TagBasedLexerFormatter.java:160)

The bug has almost 60 reports.
        at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.process(TagBasedLexerFormatter.java:155)
        at org.netbeans.modules.web.core.syntax.indent.JspIndentTask.reindent(JspIndentTask.java:52)
        at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.runTask(TaskHandler.java:498)
        at org.netbeans.modules.editor.indent.TaskHandler.runTasks(TaskHandler.java:267)
        at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:285)
Comment 1 Jan Lahoda 2008-07-09 09:37:30 UTC
Has anybody seen this in a recent builds (*)? If so, please attach a stack trace from a recent build and reopen.
Otherwise, this seems to  be already fixed as part of issue #134217:
http://hg.netbeans.org/main/rev/979ca7bbfe0a

(*): on statistics, there are reports that claim to be from "080702" - but the line numbers do not match recent sources
(last change to this file as June 12).
Comment 2 Jindrich Sedek 2008-07-09 09:58:20 UTC
latest stacktraces are comming from 61 fixes branch - that the reason of incorrect line numbers against trunk
Comment 3 Petr Blaha 2008-07-09 10:03:11 UTC
I think we should port AIOOBE fix in relase61 clone and release the fix in patch3.
Comment 4 Jindrich Sedek 2008-07-09 10:45:23 UTC
I'm not able to reproduce on latest buils neither on 6.1. I would like to kindly ask reporters, who reported the 
problem using IDE if they could give a sample file where they are able to reproduce the problem. This issue has lot's 
of duplicates and it would be good to be sure it's fixed.
Comment 5 gord 2008-07-09 20:57:15 UTC
I'm using NB61, patch2 where this occurs in EVERY JSP page (I will attach one) where the file had been opened with NB60
and forced the formatting to 8 characters per indent (ignoring my 3 characters/indent setting).  

I have tried both deleting the .netbeans\6.1\var\cache and a new user dir (changed the user dir in netbeans.conf file).
 Nothing I've tried will make the reformatting work.

I had downloaded an NBM (org-netbeans-modules-web-project.nbm - I don't remember the issue number where this file was
linked) on 5/15/2008 that seemed to correct this (and hence my email to the nbusers list about a REGRESSION).  If I
remember correctly, that patch seemed to indicate that it was scheduled for inclusion into patch2 (obviously not).

I would argue that this issue should be re-opened and the fix DEFINITELY be included in patch 3.
Comment 6 gord 2008-07-09 20:59:34 UTC
Created attachment 64207 [details]
sample file from project that generates AIOOBE on reformat
Comment 7 Jan Lahoda 2008-07-18 01:08:39 UTC
jsedek: I am able to reproduce in vanilla NB6.1 using the attached file with the default indentation settings (Expand
tabs to spaces=on, Indentation Size=4, Tab Size=8).
gord: the process of getting fixes into a patch release requires (among other things) that the bug is fixed and verified
in the trunk (the bug needs to be in "resolved verified" state).
Comment 8 Jindrich Sedek 2008-07-18 09:55:48 UTC
finally I'm able to reproduce the problem
I use 6.1 fixes build from 2008-07-02_03-01-08 :
 smetiste.czech.sun.com/builds/netbeans/6.1/fixes/2008-07-02_03-01-08/zip/

start NB with fresh userdir
open attached project
use tools/options/editor/indentation and disable expand tabs to spaces
close option
open index.jsp
invoke reformat 
AIOOBE is thrown with these line numbers:
java.lang.ArrayIndexOutOfBoundsException: 72
	at org.netbeans.modules.editor.indent.api.IndentUtils.cachedOrCreatedIndentString(IndentUtils.java:228)
	at org.netbeans.modules.editor.indent.api.IndentUtils.createIndentString(IndentUtils.java:195)
	at org.netbeans.modules.editor.indent.spi.Context.modifyIndent(Context.java:177)
	at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.reformat(TagBasedLexerFormatter.java:358)
	at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.reformat(TagBasedLexerFormatter.java:160)
	at org.netbeans.modules.editor.structure.formatting.TagBasedLexerFormatter.process(TagBasedLexerFormatter.java:155)

I'll reopen this issue since a patch for 6.1 is needed

I'm not able to reproduce in trunk - it's blocked by issue #139831
Comment 9 Jindrich Sedek 2008-07-18 09:56:33 UTC
Created attachment 64932 [details]
tested project
Comment 10 Jan Lahoda 2008-07-18 23:44:11 UTC
Not sure why the bug was reopened - the bug should be reopened only if the problem is not actually fixed in the trunk.
Please note that the bug needs to be resolved verified in order to be included in a patch release.

I am attaching editor.indent module built from the release61_fixes branch with the fix for this problem and a mercurial
bundle that contains the fix. Someone please verify the fix.
Comment 11 Jan Lahoda 2008-07-18 23:46:13 UTC
Created attachment 65006 [details]
release61_fixes version of editor.indent with the fix. Backup the original file in ide9/modules and replace it with the new one.
Comment 12 Jan Lahoda 2008-07-18 23:46:39 UTC
Created attachment 65007 [details]
Mercurial bundle with the fix.
Comment 13 Jindrich Sedek 2008-07-22 09:42:39 UTC
verified on 6.1 builds
Comment 14 rbalada 2008-07-24 15:37:02 UTC
Correct me if I'm wrong, but based on the attached bundled changegroup and stacktraces it looks like this issue 139350
is pretty clear duplicate of the issue 134217.

Please re-evaluate nomination of this duplicate issue, because the fix was in fact done for issue 134217 and the
changegroup bundle attached by jlahoda contains reference to issue 134217 (not 139350) in commit log. This would make a
fix for issue 134217 appear in NB 6.1 Patch3 w/o any reason, while the patch for issue 139350 would not be easily
identifiable by commit log text.

I suggest to do following:
#1 remove 61fixes3-candidate keyword from status whiteboard of this issue 139350
#2 put the keyword 61fixes3-candidate to status whiteboard of the issue 134217
#3 reopen&close this issue 139350 as a duplicate of issue 134217
#4 (formally) verify issue 134217

Any thoughts/suggestions are welcome,
-R

Comment 15 rbalada 2008-07-29 14:21:51 UTC
I've discussed with Petr Blaha (blaha) and we agreed on not changing the keywords as it turned out the changeset
http://hg.netbeans.org/main/rev/979ca7bbfe0a is actually a subset of solution for issue 134217, which also depends on
resolution of issue 90403, which is not acceptable for NB 6.1 fixes. In this the solution would be to use the changeset
http://hg.netbeans.org/main/rev/979ca7bbfe0a and change just commit log to match this particular issue.
Comment 16 rbalada 2008-07-29 14:39:44 UTC
I've transplanted the changeset http://hg.netbeans.org/main/rev/979ca7bbfe0a into release61_fixes repository as
http://hg.netbeans.org/release61_fixes/rev/bdeaaf094a95

I've changed commit message, but kept authorship and timestamp.

changeset:   77854:bdeaaf094a95
tag:         tip
user:        Vita Stejskal <vstejskal@netbeans.org>
date:        Mon May 05 12:46:22 2008 +0200
summary:     #139350: ArrayIndexOutOfBoundsException: 8