commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gl...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp DelegatingConnection.java DelegatingPreparedStatement.java DelegatingStatement.java PoolableConnection.java
Date Fri, 28 Jun 2002 15:28:21 GMT
glenn       2002/06/28 08:28:21

  Modified:    dbcp/src/java/org/apache/commons/dbcp
                        DelegatingConnection.java
                        DelegatingPreparedStatement.java
                        DelegatingStatement.java PoolableConnection.java
  Log:
  Fix a memory leak when tracing abandoned connections.
  Cleanup of passivate and close methods.
  
  Revision  Changes    Path
  1.5       +16 -15    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingConnection.java
  
  Index: DelegatingConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingConnection.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DelegatingConnection.java	16 May 2002 21:25:37 -0000	1.4
  +++ DelegatingConnection.java	28 Jun 2002 15:28:20 -0000	1.5
  @@ -162,16 +162,6 @@
        */
       public void close() throws SQLException
       {
  -        // The JDBC spec requires that a Connection close any open  
  -        // Statement's when it is closed.
  -        List statements = getTrace();
  -        if( statements != null) {
  -            Iterator it = statements.iterator();
  -            while(it.hasNext()) {
  -                ((ResultSet)it.next()).close();
  -            }
  -            clearTrace();
  -        }
           passivate();
           _conn.close();
       }
  @@ -256,8 +246,19 @@
           }
       }
   
  -    protected void passivate() {
  +    protected void passivate() throws SQLException {
           _closed = true;
  +        // The JDBC spec requires that a Connection close any open
  +        // Statement's when it is closed.
  +        List statements = getTrace();
  +        if( statements != null) {
  +            Iterator it = statements.iterator();
  +            while(it.hasNext()) {
  +                ((Statement)it.next()).close();
  +            }
  +            clearTrace();
  +        }  
  +        setLastUsed(0);
           if(_conn instanceof DelegatingConnection) {
               ((DelegatingConnection)_conn).passivate();
           }
  
  
  
  1.4       +19 -20    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingPreparedStatement.java
  
  Index: DelegatingPreparedStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingPreparedStatement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DelegatingPreparedStatement.java	16 May 2002 21:25:37 -0000	1.3
  +++ DelegatingPreparedStatement.java	28 Jun 2002 15:28:20 -0000	1.4
  @@ -152,22 +152,6 @@
        * any ResultSets that were not explicitly closed.
        */
       public void close() throws SQLException {
  -        if(_conn != null) {
  -            _conn.removeTrace(this);
  -           _conn = null;
  -        }
  -
  -        // The JDBC spec requires that a statment close any open  
  -        // ResultSet's when it is closed.
  -        List resultSets = getTrace();
  -        if( resultSets != null) {
  -            Iterator it = resultSets.iterator();
  -            while(it.hasNext()) {
  -                ((ResultSet)it.next()).close(); 
  -            }
  -            clearTrace();
  -        }
  -
           passivate();
           _stmt.close();
       }
  @@ -269,8 +253,23 @@
           }
       }
   
  -    protected void passivate() {
  +    protected void passivate() throws SQLException {
           _closed = true;
  +        if(_conn != null) {
  +            _conn.removeTrace(this);
  +           _conn = null;
  +        }
  +         
  +        // The JDBC spec requires that a statment close any open
  +        // ResultSet's when it is closed.
  +        List resultSets = getTrace();
  +        if( resultSets != null) {
  +            Iterator it = resultSets.iterator();
  +            while(it.hasNext()) {
  +                ((ResultSet)it.next()).close();
  +            }
  +            clearTrace();
  +        }
           if(_stmt instanceof DelegatingPreparedStatement) {
               ((DelegatingPreparedStatement)_stmt).passivate();
           }
  
  
  
  1.4       +19 -20    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java
  
  Index: DelegatingStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DelegatingStatement.java	16 May 2002 21:25:38 -0000	1.3
  +++ DelegatingStatement.java	28 Jun 2002 15:28:20 -0000	1.4
  @@ -147,22 +147,6 @@
        * any ResultSets that were not explicitly closed.
        */
       public void close() throws SQLException {
  -        if (_conn != null) {
  -            _conn.removeTrace(this);
  -           _conn = null;
  -        }
  -
  -        // The JDBC spec requires that a statment close any open  
  -        // ResultSet's when it is closed.
  -        List resultSets = getTrace();
  -        if( resultSets != null) {
  -            Iterator it = resultSets.iterator();
  -            while(it.hasNext()) {
  -                ((ResultSet)it.next()).close();
  -            }
  -            clearTrace();
  -        }
  -
           passivate();
           _stmt.close();
       }
  @@ -222,8 +206,23 @@
           }
       }
   
  -    protected void passivate() {
  +    protected void passivate() throws SQLException {
           _closed = true;
  +        if (_conn != null) {
  +            _conn.removeTrace(this);
  +           _conn = null;
  +        }
  +
  +        // The JDBC spec requires that a statment close any open
  +        // ResultSet's when it is closed.
  +        List resultSets = getTrace();
  +        if( resultSets != null) {
  +            Iterator it = resultSets.iterator();
  +            while(it.hasNext()) {
  +                ((ResultSet)it.next()).close();
  +            }
  +            clearTrace();
  +        }
           if(_stmt instanceof DelegatingPreparedStatement) {
               ((DelegatingPreparedStatement)_stmt).passivate();
           }
  
  
  
  1.4       +4 -5      jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolableConnection.java
  
  Index: PoolableConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolableConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PoolableConnection.java	16 May 2002 21:25:38 -0000	1.3
  +++ PoolableConnection.java	28 Jun 2002 15:28:20 -0000	1.4
  @@ -107,7 +107,6 @@
        */
       public void close() throws SQLException {
           try {
  -            setLastUsed(0);
               _pool.returnObject(this);
           } catch(SQLException e) {
               throw e;
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message