jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34703] New: - Invalid synchronization in PageData leads to java.lang.IllegalThreadStateException
Date Mon, 02 May 2005 11:18:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34703>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34703

           Summary: Invalid synchronization in PageData leads to
                    java.lang.IllegalThreadStateException
           Product: Taglibs
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Scrape Taglib
        AssignedTo: taglibs-dev@jakarta.apache.org
        ReportedBy: brett_s_r@yahoo.com.au


A problem with thread synchronization in org.apache.taglibs.scrape.PageData
leads to a java.lang.IllegalThreadStateException.  Looking at PageData CVS rev 1.15.

In scrapePage(), a synchronized(scraping) attempts to protect the instantiation
and start()-ing of the new Page object (Thread).  This fails however, as
scraping is an instance variable, and whilst still inside the critical section,
scraping is reassigned:

scraping = new Boolean(true);

... unprotecting the critical section.  The result is that it is possible for
two threads to attempt to start() the same page object, resulting in:

java.lang.IllegalThreadStateException
	at java.lang.Thread.start(Native Method)
	at org.apache.taglibs.scrape.PageData.scrapePage(PageData.java:549)
	at org.apache.taglibs.scrape.PageTag.doEndTag(PageTag.java:152)
	at org.apache.jsp.scrap_jsp._jspService(scrap_jsp.java:165)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)

Recommended solution: don't use "scraping" as the mutex if it needs to be
reassigned during the critical section.  A second lock Object might be more
appropriate.

As per any thread-related bug, this is difficult to reproduce, as you need two
threads to hit the expiring page at once, however in this case a review of the
code should make it clear how this problem can occur, and the fix is fairly simple.

Let me know if you need a patch submitted.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message