Bug 41558

Summary: Unnecessary synchronization caused by JspFactory.getDefaultFactory while servicing JSPs
Product: Tomcat 6 Reporter: Arvind Srinivasan <arvind.srinivasan>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P4    
Version: unspecified   
Target Milestone: default   
Hardware: All   
OS: Solaris   
Attachments: Patch to avoid invoking JspFactory.getDefaultFactory in jspService
Difference in the generated code for hello_jsp.java before and after the patch

Description Arvind Srinivasan 2007-02-07 06:03:18 UTC
Tomcat version: 6.0.x trunk

Every generated JSP has 

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");

in its _jspService method.

The use of JspFactory.getDefaultFactory during request processing should be
avoided as it is a *static synchronized* method.

I have a diff that addresses this and will attach it to this bug.
Comment 1 Arvind Srinivasan 2007-02-07 06:06:56 UTC
Created attachment 19537 [details]
Patch to avoid invoking JspFactory.getDefaultFactory in jspService

The attached patch changes the .jsp-->.java generator so that
JspFactory.getDefaultFactory is invoked as a one-time operation.

The patch also consolidates JspFactory initialization in JspRuntimeContext.
Comment 2 Arvind Srinivasan 2007-02-07 06:08:14 UTC
Created attachment 19538 [details]
Difference in the generated code for hello_jsp.java before and after the patch
Comment 3 Remy Maucherat 2007-02-07 14:55:20 UTC
I did not realize this method was synchronized, so thanks for mentioning it.
There doesn't seem to be any reason for that.