Bug 13667 - super.release() not called in release() methods
Summary: super.release() not called in release() methods
Status: RESOLVED INVALID
Alias: None
Product: Taglibs
Classification: Unclassified
Component: DBTags Taglib (show other bugs)
Version: unspecified
Hardware: All All
: P3 major with 3 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-15 19:47 UTC by Loren Halvorson
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Loren Halvorson 2002-10-15 19:47:29 UTC
Almost every tag forgets to call super.release() In their release() method.  
This doesn't cause any problems if your container doesn't recycle tags.  But if 
you are using Tomcat 4.1.x and have multiple instances of the tags on the same 
page, the page buffer from the previous instance can be reused in the second in 
some situations.

  public void release() {
    super.release();  <--- this needs to be added
    _position = -1;
    _attributeName = null;
    _name = null;
    _scope = "page";
    _tag = null;
    _metaData = null;
    _locale = null;
  }

For more detailed info see the posts I made to the taglib user list starting 
here:
http://www.mail-archive.com/taglibs-user%40jakarta.apache.org/msg03439.html

If we have two statements on the same page, where the first one returns
rows, but the second does not, the second statement tag prints out the
actual text of it's query instead of nothing.

For example:
  <sql:statement id="stmt2" conn="conn">
    <sql:query>select * from foo/*a query that returns rows*/</sql:query>
    <sql:resultSet id="rset2">
    </sql:resultSet>
  </sql:statement>

  <sql:statement id="stmt3" conn="conn">
    <sql:query>select * from bar /*a query that returns NO
rows*/</sql:query>
    <sql:resultSet id="rset3">
    </sql:resultSet>
  </sql:statement>
Would actually send back to the browser

  "select * from bar /*a query that returns NO rows*/"

In the following example, the second resultSet outputs all of the items from the
_first_ query.

------------First Query returns rows-----------
<%  java.sql.Statement stmt2 = conn.createStatement();
    java.sql.ResultSet rset2 = stmt2.executeQuery("SELECT * FROM foo");
    pageContext.setAttribute("rset2", rset2); 
%>
    <sql:resultSet id="rset2b" name="rset2" scope="page">
        <sql:getColumn colName="IndexedID"/>
    </sql:resultSet>
<%  rset2.close();
    stmt2.close();
%>
----------Second Query returns NO rows-----------
<%  java.sql.Statement stmt3 = conn.createStatement();
    java.sql.ResultSet rset3 = stmt3.executeQuery("SELECT * FROM bar);
    pageContext.setAttribute("rset3", rset3);
%>
    <sql:resultSet id="rset3b" name="rset3" scope="page">
        <sql:getColumn colName="IndexedID"/>  <--- BUG BUG outputs all items
from first query!!
    </sql:resultSet>
<%  rset3.close();
    stmt3.close();
%>
Comment 1 Felipe Leme 2004-02-27 03:17:31 UTC
Loren,

The release() method is not related to this problem - see bug 16001

Anyway, I'm closing this bug because bug 26863 fixes the issue in your example.

Felipe