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 55628

Summary: Editing JSP consumes processor in some contexts
Product: javaee Reporter: zikmund <zikmund>
Component: JSPAssignee: Marek Fukala <mfukala>
Status: CLOSED FIXED    
Severity: blocker CC: issues, mmetelka, mroskanin
Priority: P2 Keywords: PERFORMANCE, REGRESSION
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Proposed patch

Description zikmund 2005-02-28 17:13:13 UTC
Build 200502271900

1) Have fresh userdir
2) Create new Web Project
3) Edit index.jsp
4) Type at line 14:
   <%/*%>
(unfinished Java comment)
5) Place cursor at the end of this modified line 14
6) Hold any key for a while
7) ERROR:
It takes 100% of my processor.

Notice:
- Doing the same thing at line 37 (last JSP line)
takes only 52% of processor.
- Same case without <%/*%> text takes 42% of processor
Comment 1 Marek Fukala 2005-03-02 12:55:24 UTC
I will take a look at it.
Comment 2 Marek Fukala 2005-03-02 17:09:21 UTC
CCing editor guys.
Comment 3 Marek Fukala 2005-03-02 17:10:01 UTC
The problem is caused by the unclosed java comment in the scriptlet.
When JSP parser parses the line it runs java syntax parser on the
scriptlet code and waits for java parser to return error token (e.g.
%>). But inside java comment almost nothing is error, so the java
parser parses the document from the scriptlet start offset to the end
of the document. This takes very long time ofcourse. Since the
javaparser returns one big token for java block comment, there is not
easy way how to fix in on the side of jsp multisystax parser. 

A simple solution can be to divide the java block tokens by lines. The
change in java syntax is simple and it seems that the change doesn't
break anything. A proposed patch is attached. After applying this
patch the performance improvement is huge! Note that for more than 200
lines long JSPs with the <% /* %> on the beginning of the file the
performance is terrible. You cannot write, you almost cannot navigate
over the file.

Milo, Mato, please consider the proposed fix and let me know your
opinions.
Comment 4 Marek Fukala 2005-03-02 17:13:18 UTC
Created attachment 20630 [details]
Proposed patch
Comment 5 Miloslav Metelka 2005-03-03 00:14:48 UTC
I would prefer to have a boolean flag for this in an extra constructor
of the JavaSyntax used solely by JSP to not cause any regressions in
the java editor. Having that I'm OK with the patch.
Comment 6 Marek Fukala 2005-03-03 07:16:49 UTC
Sounds good to me. I will do that. Thanks.
Comment 7 Petr Pisl 2005-03-03 07:55:46 UTC
For me is the solution with the flag good as well. 
Comment 8 Marek Fukala 2005-03-03 09:21:29 UTC
fixed

Checking in
java/editor/lib/src/org/netbeans/editor/ext/java/JavaSyntax.java;
/cvs/java/editor/lib/src/org/netbeans/editor/ext/java/JavaSyntax.java,v
 <--  JavaSyntax.java
new revision: 1.3; previous revision: 1.2
done
Processing log script arguments...
More commits to come...
Checking in
web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JSPKit.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JSPKit.java,v
 <--  JSPKit.java
new revision: 1.18; previous revision: 1.17
done
Comment 9 zikmund 2005-03-07 11:17:46 UTC
Verified in 200503061900.
Although I discovered similar performance problem - see reopened issue
55525.
Comment 10 zikmund 2005-03-07 11:17:58 UTC
v