commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r377787 - /jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Date Tue, 14 Feb 2006 17:50:28 GMT
Author: rdonkin
Date: Tue Feb 14 09:50:26 2006
New Revision: 377787

URL: http://svn.apache.org/viewcvs?rev=377787&view=rev
Log:
Eliminate unnecessary exception chaining. Contributed by Sandy McArthur. Issue #38625.

Modified:
    jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Modified: jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=377787&r1=377786&r2=377787&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Tue Feb 14 09:50:26 2006
@@ -770,7 +770,6 @@
     public synchronized Object borrowObject() throws Exception {
         assertOpen();
         long starttime = System.currentTimeMillis();
-        boolean newlyCreated = false;
         for(;;) {
             ObjectTimestampPair pair = null;
 
@@ -825,22 +824,17 @@
             _numActive++;
 
             // create new object when needed
+            boolean newlyCreated = false;
             if(null == pair) {
                 try {
                     Object obj = _factory.makeObject();
                     pair = new ObjectTimestampPair(obj);
                     newlyCreated = true;
-                }
-                catch (Throwable e) {
-                    // object cannot be created
-                    _numActive--;
-                    notifyAll();
-                    if (e instanceof Exception) {
-                        throw (Exception) e;
-                    } else if (e instanceof Error) {
-                        throw (Error) e;
-                    } else {
-                        throw new Exception(e);
+                } finally {
+                    if (!newlyCreated) {
+                        // object cannot be created
+                        _numActive--;
+                        notifyAll();
                     }
                 }
             }



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