[Opensource] is a bug ?

Pierre Mergaux pmergaux at noos.fr
Mon Jan 6 04:46:13 PST 2003


in DBConnectionPool  line 384 and ... we find

                    vecConnectionsToBeRemoved.addElement(new 
Integer(oneConnection.getId()));

                    oneConnection.disconnect();
                    oneConnection.setAvailable(false);
                }
            } /* for each connection in the pool */

                /* Now iterate that vector and remove the connection 
objects from the hashmap
                        This is done to avoid the 
ConcurrentModificationException*/
            if(bCheckToRemove){
                for(int i=0; i<vecConnectionsToBeRemoved.size(); i++){
                    DBConnection dbconn = 
(DBConnection)vecConnectionsToBeRemoved.elementAt(i);
              oneConnection.disconnect();
              oneConnection.setAvailable(false);
                    inUse.remove(new Integer(oneConnection.getId()));
                }

You store connection to close as an Integer (its ID), but you retreive 
it as DBConnection : conclusion CastException.
Also, you disconnect and setAvailable(false) twice. I propose

                   vecConnectionsToBeRemoved.addElement(oneConnection);
                }
            } /* for each connection in the pool */

                /* Now iterate that vector and remove the connection 
objects from the hashmap
                        This is done to avoid the 
ConcurrentModificationException*/
            if(bCheckToRemove){
                for(int i=0; i<vecConnectionsToBeRemoved.size(); i++){
                    DBConnection dbconn = 
(DBConnection)vecConnectionsToBeRemoved.elementAt(i);
              oneConnection.disconnect();
              oneConnection.setAvailable(false);
                    inUse.remove(new Integer(oneConnection.getId()));
                }

PMX





More information about the Opensource mailing list