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 97801 - SIOOBE when using CC
Summary: SIOOBE when using CC
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Pavel Flaska
URL:
Keywords: RANDOM
: 93022 99333 99613 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-14 09:38 UTC by Max Sauer
Modified: 2007-04-03 13:34 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
SIOOBE stack trace (1.44 KB, text/plain)
2007-03-14 09:41 UTC, Max Sauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Max Sauer 2007-03-14 09:38:39 UTC
When using CC to supply an element which is not yet imported, following SIOOBE
is thrown:

java.lang.StringIndexOutOfBoundsException: String index out of range: 7229
	at java.lang.String.substring(String.java:1935)
	at org.netbeans.modules.java.source.save.CasualDiff.copyTo(CasualDiff.java:2680)
	at org.netbeans.modules.java.source.save.CasualDiff.diffList(CasualDiff.java:1873)
	at
org.netbeans.modules.java.source.save.CasualDiff.diffTopLevel(CasualDiff.java:178)
	at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:2252)
...
(whole stack trace attached)

Stesp to reproduce:
-------------------
1) Open a java class, which already has some import statements, ie. >5
2) Inside of a method, type
new IOE|        //pipe stands for carret, IOE should not be imported yet
3) Press Ctrl-Space twice in order to bring up all-CC
4) Choose IOExcetion and press enter
=> SIOOBE

This issue seems to be RANDOM, but I can reproduce it fairly often.

---
NetBeans IDE Dev (Build 070314)
1.6.0_01; Java HotSpot(TM) Server VM 1.6.0_01-b04
Linux version 2.6.12-1.1390_FC4smp running on i386
en_US (nb); UTF-8
Comment 1 Max Sauer 2007-03-14 09:41:26 UTC
Created attachment 39461 [details]
SIOOBE stack trace
Comment 2 Pavel Flaska 2007-03-14 11:03:56 UTC
I have tried to reproduce it but was unsuccessful. Not sure what causes it, was
the source somehow broken or not? -- In provided information, I see your source
where it occurred is pretty long. Did you have one or more top level classes?
Comment 3 Jiri Prox 2007-03-14 14:47:08 UTC
I can reproduce it too. 

My steps to reproduce:
1) have a class ( | shows cursor position):
package javaapplication4;
public class NewClass {
           
    public void aaaa() {
        try {
            throw new java.net.ConnectException("Error");
        } catch (|
                
    }           
}
2) call CC
3) select 1st item - ConnectException
-> import is added
-> sometimes (about 25%) mentioned exception is thrown
Comment 4 Pavel Flaska 2007-03-29 11:03:14 UTC
Even worse than we expected. It looks like modification task does not see last
state of source, but token sequence has been already updated.

Cc'ing others helping with the cause.
Comment 5 Pavel Flaska 2007-03-29 20:28:00 UTC
*** Issue 99333 has been marked as a duplicate of this issue. ***
Comment 6 Tomas Zezula 2007-03-30 07:20:21 UTC
The issue has two parts. Both has to be fixed.
The first: race condition in the JavaSource
The second: TokenSequuence is built from document without snap shot, mybe it
should be built always from char buffer, but it slows down the IDE. Or the
priority of snap shots should be reevaluated.
Comment 7 Pavel Flaska 2007-03-30 13:59:16 UTC
*** Issue 93022 has been marked as a duplicate of this issue. ***
Comment 8 Pavel Flaska 2007-03-30 14:03:19 UTC
I think the problem is bigger than observed exception. P3 -> P2
Cc'ing other reporters.
Comment 9 Tomas Zezula 2007-03-30 15:38:07 UTC
I have fix of the race condition. I will test it and integrate.
Comment 10 Pavel Flaska 2007-04-02 09:39:59 UTC
*** Issue 99613 has been marked as a duplicate of this issue. ***
Comment 11 Tomas Zezula 2007-04-02 17:42:10 UTC
Checking in JavaSource.java;
/cvs/java/source/src/org/netbeans/api/java/source/JavaSource.java,v  <-- 
JavaSource.java
new revision: 1.34; previous revision: 1.33
done
Comment 12 Max Sauer 2007-04-03 13:24:06 UTC
I cannot reproduce this anymore. Marking as VERIFIED.
---
NetBeans IDE Dev (Build 070403)
1.6.0_01; Java HotSpot(TM) Server VM 1.6.0_01-b04
Linux version 2.6.12-1.1390_FC4smp running on i386
en_US (nb); UTF-8
Comment 13 Pavel Flaska 2007-04-03 13:34:03 UTC
I have tried it in old build (where it was mostly reproducible) and after the
fix in current build and cannot reproduce too.