commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp PoolableConnectionFactory.java PoolingConnection.java
Date Wed, 02 Apr 2003 00:48:49 GMT
rwaldhoff    2003/04/01 16:48:49

  Modified:    dbcp/src/java/org/apache/commons/dbcp/cpdsadapter
                        PooledConnectionImpl.java
               dbcp/src/java/org/apache/commons/dbcp/jdbc2pool
                        KeyedCPDSConnectionFactory.java
                        CPDSConnectionFactory.java
               dbcp/src/java/org/apache/commons/dbcp
                        PoolableConnectionFactory.java
                        PoolingConnection.java
  Log:
  no longer ignore checked exceptions
  
  Revision  Changes    Path
  1.5       +8 -26     jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java
  
  Index: PooledConnectionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PooledConnectionImpl.java	6 Mar 2003 19:25:37 -0000	1.4
  +++ PooledConnectionImpl.java	2 Apr 2003 00:48:49 -0000	1.5
  @@ -368,22 +368,12 @@
        * @param key ignored
        * @param obj the {*link PreparedStatement} to be destroyed.
        */
  -    public void destroyObject(Object key, Object obj) {
  +    public void destroyObject(Object key, Object obj) throws Exception {
           //_openPstmts--;
  -        try {
  +        if(obj instanceof DelegatingPreparedStatement) {
               ((DelegatingPreparedStatement)obj).getInnermostDelegate().close();
  -        } catch(SQLException e) {
  -            // ignored
  -        } catch(NullPointerException e) {
  -            // ignored
  -        } catch(ClassCastException e) {
  -            try {
  -                ((PreparedStatement)obj).close();
  -            } catch(SQLException e2) {
  -                // ignored
  -            } catch(ClassCastException e2) {
  -                // ignored
  -            }
  +        } else {
  +            ((PreparedStatement)obj).close();
           }
       }
   
  @@ -414,17 +404,9 @@
        * @param key ignored
        * @param obj a {*link PreparedStatement}
        */
  -    public void passivateObject(Object key, Object obj) {
  -        try {
  -            ((PreparedStatement)obj).clearParameters();
  -            ((PoolablePreparedStatementStub)obj).passivate();
  -        } catch(SQLException e) {
  -            // ignored
  -        } catch(NullPointerException e) {
  -            // ignored
  -        } catch(ClassCastException e) {
  -            // ignored
  -        }
  +    public void passivateObject(Object key, Object obj) throws Exception {
  +        ((PreparedStatement)obj).clearParameters();
  +        ((PoolablePreparedStatementStub)obj).passivate();
       }
   
       /**
  
  
  
  1.5       +20 -14    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/KeyedCPDSConnectionFactory.java
  
  Index: KeyedCPDSConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/KeyedCPDSConnectionFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- KeyedCPDSConnectionFactory.java	6 Mar 2003 19:25:38 -0000	1.4
  +++ KeyedCPDSConnectionFactory.java	2 Apr 2003 00:48:49 -0000	1.5
  @@ -179,15 +179,9 @@
           return obj;
       }
   
  -    public void destroyObject(Object key, Object obj) {
  +    public void destroyObject(Object key, Object obj) throws Exception {
           if(obj instanceof PooledConnectionAndInfo) {
  -            try {
  -                ((PooledConnectionAndInfo)obj).getPooledConnection().close();
  -            } catch(RuntimeException e) {
  -                throw e;
  -            } catch(SQLException e) {
  -                ; // ignored
  -            }
  +            ((PooledConnectionAndInfo)obj).getPooledConnection().close();
           }
       }
   
  @@ -281,9 +275,15 @@
               }
               catch (Exception e)
               {
  -                destroyObject(info.getUserPassKey(), info);
                   System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + 
                                      "NOT BE RETURNED TO THE POOL");
  +                try {
  +                    destroyObject(info.getUserPassKey(), info);
  +                } catch(Exception e2) {
  +                    System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + 
  +                                       info);
  +                    e2.printStackTrace();
  +                }
               }
           }
       }
  @@ -316,7 +316,13 @@
           {
               throw new IllegalStateException(NO_KEY_MESSAGE);
           }            
  -        destroyObject(info.getUserPassKey(), info);
  +        try {
  +            destroyObject(info.getUserPassKey(), info);
  +        } catch(Exception e) {
  +            System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + 
  +                               info);
  +            e.printStackTrace();
  +        }
       }
   
       private static final String NO_KEY_MESSAGE = 
  
  
  
  1.5       +23 -16    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/CPDSConnectionFactory.java
  
  Index: CPDSConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/CPDSConnectionFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CPDSConnectionFactory.java	6 Mar 2003 19:25:38 -0000	1.4
  +++ CPDSConnectionFactory.java	2 Apr 2003 00:48:49 -0000	1.5
  @@ -183,16 +183,10 @@
           return obj;
       }
   
  -    public void destroyObject(Object obj) {
  +    public void destroyObject(Object obj) throws Exception {
           if(obj instanceof PooledConnectionAndInfo) {
  -            try {
  -                ((PooledConnectionAndInfo)obj)
  -                    .getPooledConnection().close();
  -            } catch(RuntimeException e) {
  -                throw e;
  -            } catch(SQLException e) {
  -                ; // ignored
  -            }
  +            ((PooledConnectionAndInfo)obj)
  +                .getPooledConnection().close();
           }
       }
   
  @@ -267,7 +261,7 @@
        * method of this connection object. What we need to do here is to
        * release this PooledConnection from our pool...
        */
  -    public void connectionClosed(ConnectionEvent event) 
  +    public void connectionClosed(ConnectionEvent event)  
       {
           PooledConnection pc = (PooledConnection)event.getSource();
           // if this event occured becase we were validating, ignore it
  @@ -286,9 +280,16 @@
               }
               catch (Exception e)
               {
  -                destroyObject(info);
                   System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + 
                                      "NOT BE RETURNED TO THE POOL");
  +                try {
  +                    destroyObject(info);
  +                } catch(Exception e2) {
  +                    System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + 
  +                                       info);
  +                    e2.printStackTrace();
  +
  +                }
               }
           }
       }
  @@ -321,7 +322,13 @@
           {
               throw new IllegalStateException(NO_KEY_MESSAGE);
           }            
  -        destroyObject(info);
  +        try {
  +            destroyObject(info);
  +        } catch(Exception e) {
  +            System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + 
  +                               info);
  +            e.printStackTrace();
  +        }
       }
   
       private static final String NO_KEY_MESSAGE = 
  
  
  
  1.6       +9 -27     jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java
  
  Index: PoolableConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PoolableConnectionFactory.java	6 Mar 2003 15:26:07 -0000	1.5
  +++ PoolableConnectionFactory.java	2 Apr 2003 00:48:49 -0000	1.6
  @@ -192,13 +192,7 @@
   
       public void destroyObject(Object obj) throws Exception {
           if(obj instanceof PoolableConnection) {
  -            try {
  -                ((PoolableConnection)obj).reallyClose();
  -            } catch(RuntimeException e) {
  -                throw e;
  -            } catch(SQLException e) {
  -                ; // ignored
  -            }
  +            ((PoolableConnection)obj).reallyClose();
           }
       }
   
  @@ -250,12 +244,8 @@
       public void passivateObject(Object obj) throws Exception {
           if(obj instanceof Connection) {
               Connection conn = (Connection)obj;
  -            try {
  -                if(!conn.getAutoCommit()) {
  -                    conn.rollback();
  -                }
  -            } catch(SQLException e) {
  -                ; // ignored
  +            if(!conn.getAutoCommit()) {
  +                conn.rollback();
               }
           }
           if(obj instanceof DelegatingConnection) {
  @@ -269,16 +259,8 @@
           }
           if(obj instanceof Connection) {
               Connection conn = (Connection)obj;
  -            try {
  -                conn.setAutoCommit(_defaultAutoCommit);
  -            } catch(SQLException e) {
  -                ; // ignored
  -            }
  -            try {
  -                conn.setReadOnly(_defaultReadOnly);
  -            } catch(SQLException e) {
  -                ; // ignored
  -            }
  +            conn.setAutoCommit(_defaultAutoCommit);
  +            conn.setReadOnly(_defaultReadOnly);
           }
       }
   
  
  
  
  1.4       +10 -28    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java
  
  Index: PoolingConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PoolingConnection.java	20 Jul 2002 22:55:34 -0000	1.3
  +++ PoolingConnection.java	2 Apr 2003 00:48:49 -0000	1.4
  @@ -198,22 +198,12 @@
        * @param key ignored
        * @param obj the {@link PreparedStatement} to be destroyed.
        */
  -    public void destroyObject(Object key, Object obj) {
  +    public void destroyObject(Object key, Object obj) throws Exception {
           //_openPstmts--;
  -        try {
  +        if(obj instanceof DelegatingPreparedStatement) {
               ((DelegatingPreparedStatement)obj).getInnermostDelegate().close();
  -        } catch(SQLException e) {
  -            // ignored
  -        } catch(NullPointerException e) {
  -            // ignored
  -        } catch(ClassCastException e) {
  -            try {
  -                ((PreparedStatement)obj).close();
  -            } catch(SQLException e2) {
  -                // ignored
  -            } catch(ClassCastException e2) {
  -                // ignored
  -            }
  +        } else {
  +            ((PreparedStatement)obj).close();
           }
       }
   
  @@ -244,17 +234,9 @@
        * @param key ignored
        * @param obj a {@link PreparedStatement}
        */
  -    public void passivateObject(Object key, Object obj) {
  -        try {
  -            ((PreparedStatement)obj).clearParameters();
  -            ((DelegatingPreparedStatement)obj).passivate();
  -        } catch(SQLException e) {
  -            // ignored
  -        } catch(NullPointerException e) {
  -            // ignored
  -        } catch(ClassCastException e) {
  -            // ignored
  -        }
  +    public void passivateObject(Object key, Object obj) throws Exception {
  +        ((PreparedStatement)obj).clearParameters();
  +        ((DelegatingPreparedStatement)obj).passivate();
       }
   
       public String toString() {
  
  
  

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


Mime
View raw message