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 201841 - [71cat] IndexOutOfBoundsException: Invalid line index=111 >= lineCount=104
Summary: [71cat] IndexOutOfBoundsException: Invalid line index=111 >= lineCount=104
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 16:00 UTC by gualtiero65
Modified: 2012-06-20 07:58 UTC (History)
10 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 181039


Attachments
stacktrace (3.66 KB, text/plain)
2011-09-08 16:00 UTC, gualtiero65
Details
stacktrace (3.63 KB, text/plain)
2011-09-13 07:03 UTC, muellermi
Details
stacktrace (1.33 KB, text/plain)
2011-09-20 17:16 UTC, Jesse Glick
Details
stacktrace (1.33 KB, text/plain)
2011-09-20 17:34 UTC, Jesse Glick
Details
stacktrace (3.63 KB, text/plain)
2011-09-21 00:13 UTC, Exceptions Reporter
Details
stacktrace (3.80 KB, text/plain)
2011-09-27 11:05 UTC, muellermi
Details
stacktrace (3.65 KB, text/plain)
2011-09-27 12:04 UTC, sunbiz
Details
stacktrace (3.80 KB, text/plain)
2011-09-28 09:34 UTC, muellermi
Details
stacktrace (3.82 KB, text/plain)
2011-09-29 18:23 UTC, mago_ebon
Details
stacktrace (2.36 KB, text/plain)
2011-09-30 11:26 UTC, Jiri Skrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gualtiero65 2011-09-08 16:00:14 UTC
Build: NetBeans IDE Dev (Build 201109060600)
VM: Java HotSpot(TM) Client VM, 20.2-b06, Java(TM) SE Runtime Environment, 1.6.0_27-b07
OS: Linux

User Comments:
gualtiero65: Hi
I was fixing import  on a line using the hint.

Line was:
                BufferedReader br = new BufferedReader(new FileReader(strFile));

and package FileReader was marked as to be imported.

On the background there was a plugin installation running (I was installing Netbeans API documentation).




Stacktrace: 
java.lang.IndexOutOfBoundsException: Invalid line index=111 >= lineCount=104
   at org.netbeans.modules.editor.lib2.document.LineElementRoot.getElement(LineElementRoot.java:66)
   at org.openide.text.NbDocument$DocumentRenderer.run(NbDocument.java:691)
   at org.netbeans.editor.BaseDocument.render(BaseDocument.java:1404)
   at org.openide.text.NbDocument$DocumentRenderer.renderToInt(NbDocument.java:666)
   at org.openide.text.NbDocument.findLineOffset(NbDocument.java:187)
   at org.openide.text.DocumentLine$Set.offset(DocumentLine.java:1066)
Comment 1 gualtiero65 2011-09-08 16:00:19 UTC
Created attachment 110543 [details]
stacktrace
Comment 2 muellermi 2011-09-13 07:03:00 UTC
Created attachment 110687 [details]
stacktrace

click onto line number to toggle breakpoint
Comment 3 Miloslav Metelka 2011-09-19 10:56:07 UTC
org.netbeans.modules.web.beans.navigation.actions.CdiGlyphAction.performCdiAction(CdiGlyphAction.java:114)

should use Document.render(). In case the problem would persist even with read-lock. then the LineSet.getOriginal() algorithm would be wrong.
Comment 4 Jesse Glick 2011-09-20 17:15:10 UTC
I just filed a duplicate report but I am not using the Java EE support, so maybe reevaluate the component, or consider filing separate issues for miscategorized dupes.
Comment 5 Jesse Glick 2011-09-20 17:16:01 UTC
Created attachment 110925 [details]
stacktrace
Comment 6 Jesse Glick 2011-09-20 17:34:01 UTC
Created attachment 110928 [details]
stacktrace
Comment 7 Exceptions Reporter 2011-09-20 17:34:13 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=181039
Comment 8 Denis Anisimov 2011-09-20 18:19:14 UTC
(In reply to comment #3)
> org.netbeans.modules.web.beans.navigation.actions.CdiGlyphAction.performCdiAction(CdiGlyphAction.java:114)
> 
> should use Document.render(). In case the problem would persist even with
> read-lock. then the LineSet.getOriginal() algorithm would be wrong.

It's a shame that NbEditorUtilities.getLine() method doesn't have javadoc with requirement to acquire document lock .
The action is performed in the AWT thread so it's unlikely  bug in mentioned method.

I will correct the method on web.beans module to do it under document lock.
But the issue obviously is not in web.beans module.
The two stacktraces from Jesse don't contain any mentions of CDI .
So the issue is in editor support.

I will reassign it after correction on web.beans side.
Comment 9 Exceptions Reporter 2011-09-21 00:13:02 UTC
Created attachment 110938 [details]
stacktrace

I clicked on the red circular error indicator on the left side of the editor.
Comment 10 Denis Anisimov 2011-09-21 05:38:50 UTC
correction in the web.beans module:
web-main#a3f609274439
Comment 11 Denis Anisimov 2011-09-21 05:39:59 UTC
Please set appropriate component because I don't know what it is exactly.
Thanks.
Comment 12 Miloslav Metelka 2011-09-21 12:43:14 UTC
I noticed that

org.netbeans.modules.web.beans.navigation.actions.CdiGlyphAction.performCdiAction(CdiGlyphAction.java:119)

uses

Line line = NbEditorUtilities.getLine(document, dot, true);

so original line is requested for caret's position. This is almost certainly wrong since in case when e.g. several new lines were added to the end of doc and that code would be run the IIOBE exception would be thrown because originally (before the modifications were done in the document) there was no line with such number. 'false' should be passed into getLine() to get current line. Reassigning to web.beans.
Comment 13 muellermi 2011-09-27 11:05:49 UTC
Created attachment 111233 [details]
stacktrace

Click onto line numbers to toggle breakpoint
Comment 14 sunbiz 2011-09-27 12:04:35 UTC
Created attachment 111236 [details]
stacktrace

Clicked on line number gutter with expectation of seeing hints and got this error
Comment 15 Denis Anisimov 2011-09-28 04:35:40 UTC
(In reply to comment #12)
> I noticed that
> 
> org.netbeans.modules.web.beans.navigation.actions.CdiGlyphAction.performCdiAction(CdiGlyphAction.java:119)
> 
> uses
> 
> Line line = NbEditorUtilities.getLine(document, dot, true);
> 
> so original line is requested for caret's position. This is almost certainly
> wrong since in case when e.g. several new lines were added to the end of doc
> and that code would be run the IIOBE exception would be thrown because
> originally (before the modifications were done in the document) there was no
> line with such number. 'false' should be passed into getLine() to get current
> line. Reassigning to web.beans.

Could you PLEASE look at other stacktraces ?
They don't contain J2EE functionality AT ALL .

So either this is a common problem across usages of this code in many places or this is a bug in the Editor.

I will change method argument as you suggest and add comment here about my commit.
But please evaluate other stacktraces. I will reassign back it.
Comment 16 muellermi 2011-09-28 09:34:34 UTC
Created attachment 111269 [details]
stacktrace

Clicking onto line number to toggle breakpoint
Comment 17 Exceptions Reporter 2011-09-28 09:34:47 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=181039
Comment 18 Denis Anisimov 2011-09-28 13:10:30 UTC
Change third argument in getLine() method from "true" to "false".
web-main#797d227648e5
Comment 19 Milutin Kristofic 2011-09-29 09:58:23 UTC
I read stack traces and there is also a one stack trace where org.netbeans.modules.web.beans.hints.EditorAnnotationsHelper.addAnnotation(EditorAnnotationsHelper.java:262) use also True - to get Original Line. You could consider to change it.

I also separated stacktraces from apisupport.refactoring.
Comment 20 Quality Engineering 2011-09-29 14:10:17 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/797d227648e5
User: Denis Anisimov <ads@netbeans.org>
Log: Requested correction from BZ#201841 - [71cat] IndexOutOfBoundsException: Invalid line index=111 >= lineCount=104 .
Comment 21 Denis Anisimov 2011-09-29 15:37:11 UTC
(In reply to comment #19)
> I read stack traces and there is also a one stack trace where
> org.netbeans.modules.web.beans.hints.EditorAnnotationsHelper.addAnnotation(EditorAnnotationsHelper.java:262)
> use also True - to get Original Line. You could consider to change it.
> 
Thank you.

web-main#ef1ecaa9202b
Comment 22 mago_ebon 2011-09-29 18:23:42 UTC
Created attachment 111329 [details]
stacktrace

I was setting a breakpoint in a test .java file.
Comment 23 Exceptions Reporter 2011-09-29 18:23:57 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=181039
Comment 24 mago_ebon 2011-09-29 18:27:35 UTC
The problem arised because I was setting a breakpoint in a file that I had just edited (appending lines) and wasn't already saved. The breakpoint was in the new segment of the file. Probably it's just necessary to save the file whenever someone is trying to set a breakpoint.

> Created an attachment (id=111329)
> stacktrace
> I was setting a breakpoint in a test .java file.
Comment 25 Jiri Skrivanek 2011-09-30 11:26:44 UTC
Created attachment 111359 [details]
stacktrace

To reproduce:
- create new web project
- create new qualifier (File|New|Context and Dependency Injection|Qualifier Type)
- create a new class
- modify class to contain following and fix imports. Exception is thrown repeatedly whenever you type something in.

@Decorator
public class NewClass {
    @Inject
    @Delegate
    @NewQualifier
    private int qualifier1;
}
Comment 26 Quality Engineering 2011-09-30 14:41:44 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/ef1ecaa9202b
User: Denis Anisimov <ads@netbeans.org>
Log: Correction related to BZ#201841 - [71cat] IndexOutOfBoundsException: Invalid line index=111 >= lineCount=104
Comment 27 Milutin Kristofic 2011-10-04 09:28:57 UTC
Jirka, IMHO your reported bug is fixed by the Denis' second changeset. New stacktraces are from nb's version before fixes -> I set this to fixed.
Comment 28 Petr Jiricka 2011-10-21 08:25:32 UTC
Looks like after Denis's change, there are much fewer reports of this, but I still see two reports that came from a build after this change:
http://statistics.netbeans.org/exceptions/exception.do?id=534714
http://statistics.netbeans.org/exceptions/exception.do?id=534294

Can these please be evaluated?
Comment 29 Denis Anisimov 2011-10-21 10:48:41 UTC
(In reply to comment #28)
> Looks like after Denis's change, there are much fewer reports of this, but I
> still see two reports that came from a build after this change:
> http://statistics.netbeans.org/exceptions/exception.do?id=534714
> http://statistics.netbeans.org/exceptions/exception.do?id=534294
> 
> Can these please be evaluated?

By the way they has no relation to web beans area.
Comment 30 Milutin Kristofic 2011-10-26 15:46:18 UTC
(In reply to comment #28)
> Looks like after Denis's change, there are much fewer reports of this, but I
> still see two reports that came from a build after this change:
> http://statistics.netbeans.org/exceptions/exception.do?id=534714
I send as a duplicate to php module https://netbeans.org/bugzilla/show_bug.cgi?id=203427

> http://statistics.netbeans.org/exceptions/exception.do?id=534294

it's user defined parser.  at coffeescript.nb.CoffeeScriptParser$ParsingResult.getDiagnostics(CoffeeScriptParser.java:104)

> 
> Can these please be evaluated?