Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004964 [Resin] major always 02-27-12 13:53 06-15-12 15:41
Reporter mcamca View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.25
Summary 0004964: ClassCastException from PageContextImpl.popBody() after call to pushBody(Writer)
Description com.caucho.jsp.PageContextImpl implements 2 versions of the pushBody() method:

BodyContent pushBody();
JspWriter pushBody(Writer writer);

However, its implementation of JspContext.popBody() performs a cast that assumes the no-args version of pushBody() was called. If the second form of pushBody() was called, then popBody() will fail with an exception like this:

java.lang.ClassCastException: com.caucho.jsp.StreamJspWriter cannot be cast to com.caucho.jsp.BodyContentImpl
    at com.caucho.jsp.PageContextImpl.popBody(PageContextImpl.java:683)
    [...]

I have observed this behavior in Resin 3.1.9 and 4.0.25. The following code change made the problem go away for me, but I'm not sufficiently familiar with Resin's code base to know if it's the best, or even a good, solution.

Index: modules/resin/src/com/caucho/jsp/PageContextImpl.java
===================================================================
--- modules/resin/src/com/caucho/jsp/PageContextImpl.java (revision 5126)
+++ modules/resin/src/com/caucho/jsp/PageContextImpl.java (working copy)
@@ -673,8 +673,7 @@
    */
   public JspWriter popBody()
   {
- BodyContentImpl bodyOut = (BodyContentImpl) _out;
- _out = bodyOut.getEnclosingWriter();
+ _out = ((AbstractJspWriter) _out).getEnclosingWriter();
 
     try {
       _bodyResponseStream.flushBuffer();
Index: modules/resin/src/com/caucho/jsp/StreamJspWriter.java
===================================================================
--- modules/resin/src/com/caucho/jsp/StreamJspWriter.java (revision 5126)
+++ modules/resin/src/com/caucho/jsp/StreamJspWriter.java (working copy)
@@ -41,8 +41,6 @@
   private Writer _writer;
   
   private JspPrintWriter _printWriter;
-
- private JspWriter _parent;
   
   // the page context
   private PageContextImpl _pageContext;
@@ -63,7 +61,7 @@
    */
   void init(JspWriter parent, Writer writer)
   {
- _parent = parent;
+ setParent(parent);
     _writer = writer;
     _isClosed = false;
   }
Additional Information
Attached Files

- Relationships

- Notes
(0005860)
ferg
06-15-12 15:41

jsp/162h
 

- Issue History
Date Modified Username Field Change
02-27-12 13:53 mcamca New Issue
02-27-12 15:21 mcamca Issue Monitored: mcamca
06-15-12 15:41 ferg Note Added: 0005860
06-15-12 15:41 ferg Assigned To  => ferg
06-15-12 15:41 ferg Status new => closed
06-15-12 15:41 ferg Resolution open => fixed
06-15-12 15:41 ferg Fixed in Version  => 4.0.29


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker