commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Nielsen <gl...@mail.more.net>
Subject [DBCP] cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp AbandonedObjectPool.java
Date Sat, 04 Oct 2003 19:18:43 GMT
This patch removed to much.  Only the System.out should have been removed.
The NoSuchElementException needs to be caught so that an exception with
a message which makes sense to the user is thrown.  There is no way to know
what the NoSuchElementException means without diving into the code. This
is a user support issue, we need to tell the user what really happened in
this case rather than just passing on the exception.

Regards,

Glenn

dirkv@apache.org wrote:
> dirkv       2003/09/30 13:50:29
> 
>   Modified:    dbcp/src/java/org/apache/commons/dbcp
>                         AbandonedObjectPool.java
>   Log:
>   Bugzilla Bug 22776: DBCP should not be writing messages to stderr or stdout
>   - Do not print error messages in borrowObject (allow exceptions to pass)
>   
>   Revision  Changes    Path
>   1.11      +17 -27    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java
>   
>   Index: AbandonedObjectPool.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- AbandonedObjectPool.java	26 Sep 2003 12:45:13 -0000	1.10
>   +++ AbandonedObjectPool.java	30 Sep 2003 20:50:29 -0000	1.11
>   @@ -61,11 +61,9 @@
>    
>    package org.apache.commons.dbcp;
>    
>   -import java.sql.SQLException;
>    import java.util.ArrayList;
>    import java.util.Iterator;
>    import java.util.List;
>   -import java.util.NoSuchElementException;
>    
>    import org.apache.commons.pool.PoolableObjectFactory;
>    import org.apache.commons.pool.impl.GenericObjectPool;
>   @@ -112,30 +110,22 @@
>         * @return Object jdbc Connection
>         */
>        public Object borrowObject() throws Exception {
>   -        try {
>   -            if (config != null
>   -                    && config.getRemoveAbandoned()
>   -                    && (getNumIdle() < 2)
>   -                    && (getNumActive() > getMaxActive() - 3) ) {
>   -                removeAbandoned();
>   -            }
>   -            Object obj = super.borrowObject();
>   -            if(obj instanceof AbandonedTrace) {
>   -                ((AbandonedTrace)obj).setStackTrace();
>   -            }
>   -            if (obj != null && config != null && config.getRemoveAbandoned())
{
>   -                synchronized(trace) {
>   -                    trace.add(obj);
>   -                }
>   +        if (config != null
>   +                && config.getRemoveAbandoned()
>   +                && (getNumIdle() < 2)
>   +                && (getNumActive() > getMaxActive() - 3) ) {
>   +            removeAbandoned();
>   +        }
>   +        Object obj = super.borrowObject();
>   +        if(obj instanceof AbandonedTrace) {
>   +            ((AbandonedTrace)obj).setStackTrace();
>   +        }
>   +        if (obj != null && config != null && config.getRemoveAbandoned())
{
>   +            synchronized(trace) {
>   +                trace.add(obj);
>                }
>   -            return obj;
>   -        } catch(NoSuchElementException ne) {
>   -            throw new SQLException(
>   -                "DBCP could not obtain an idle db connection, pool exhausted");
>   -        } catch(Exception e) {
>   -            System.out.println("DBCP borrowObject failed: " + e.getMessage());
>   -            throw e;
>            }
>   +        return obj;
>        }
>    
>        /**
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 



---------------------------------------------------------------------
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