You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by BugRat Mail System <to...@cortexity.com> on 2000/09/23 01:24:07 UTC

BugRat Report #157 has been filed.

Bug report #157 has just been filed.

You can view the report at the following URL:

   <http://znutar.cortexity.com:8888/BugRatViewer/ShowReport/157>

REPORT #157 Details.

Project: Jasper
Category: Bug Report
SubCategory: New Bug Report
Class: swbug
State: received
Priority: low
Severity: critical
Confidence: public
Environment: 
   Release: tomcat 3.1, 4.0
   JVM Release: any
   Operating System: any
   OS Release: any
   Platform: any

Synopsis: 
_jspx_init() handling is not thread safe

Description:
JSP pages are translated java code containing the following fragments:

    private static boolean _jspx_inited = false;

    public final void _jspx_init() throws JasperException {
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse  re\
sponse)
        throws IOException, ServletException {

        try {
            if (_jspx_inited == false) {
                _jspx_init();
                _jspx_inited = true;
            }

This is not thread-safe.  The "if" block needs to be synchronized to
avoid surprising results.  This is true even if the operations
performed by _jspx_init() are idempotent and create only immutable
objects.  As is, the code will likely work most of the time on most
java implementations but it won't work right all of the time on all
java implementations.  See the Java Language Specification chapter 17
for a description of the java memory model and some examples of
surprising results caused by lack of synchronization.  And keep in
mind that the "java memory model" includes code motion performed by
the java compiler and jit as well as by the hardware.