Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2976

NestedRootTag and NestedPropertyTag's doStartTag() could return EVAL_BODY_INCLUDE



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.5
    • Fix Version/s: 1.4.x
    • Component/s: Tag Libraries
    • Labels:


      The nested:nest (NestedRootTag) and nested:root (NestedRootTag) only set context and scope for other tags within its body, they do not output any content themselves or manipulate the content with in their body, and yet they return EVAL_BODY_TAG (equivalent to EVAL_BODY_BUFFERED) rather than EVAL_BODY_INCLUDE. This means a new BodyContent object is created for the body rather than using the existing one (passed through to the current out).

      This can be an issue if the body of either a nested:nest or a nested:root tag generates a large amount of data because the BodyContent object of the tag's body will not flush to the underlying stream until the tag's body is complete. When running under Tomcat the BodyContent implementation is org.apache.jasper.runtime.BodyContentImpl, and because these objects are pooled and their underlying buffers (char[]) will grow (but not shrink), when rendering large pages (i.e. large content inside nested:nest or nested:root tags) the BodyContent object used for the tag's body can grow very large (because it can not flush) and will also be retained after the page has rendered (because the object is pooled - hence not released).

      I have experimented by extending the NestedPropertyTag and NestedRootTag classes and overriding the doStartTag() method in the following way:

      public int doStartTag() throws JspException

      { super.doStartTag(); return EVAL_BODY_INCLUDE; }

      In a test case, using this implementation rather than returning EVAL_BODY_TAG, meant the body of the tag could stream/flush and hence did not need to grow the BodyContent buffer. The result was that the retained memory (of BodyContentImpl) was significantly reduced (approx 35k as opposed to > 100M).

      I proposed that you change the implementation of both NestedRootTag and NestedPropertyTag's doStartTag() method to return EVAL_BODY_INCLUDE as there is no obvious reason why it needs to buffer the body.


          Issue Links



              • Assignee:
                hbfoot Hayden Foot
              • Votes:
                1 Vote for this issue
                0 Start watching this issue


                • Created: