commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r609487 - /commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Date Mon, 07 Jan 2008 02:36:43 GMT
Author: psteitz
Date: Sun Jan  6 18:36:42 2008
New Revision: 609487

URL: http://svn.apache.org/viewvc?rev=609487&view=rev
Log:
Restored synchronization to addObject.
JIRA: POOL-120
JIRA: POOL-108

Modified:
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=609487&r1=609486&r2=609487&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Sun Jan  6 18:36:42 2008
@@ -862,6 +862,7 @@
      * the pool behaves as a FIFO queue - objects are taken from the idle object
      * pool in the order that they are returned to the pool.
      * 
+     * @return <code>true</true> if the pool is configured to act as a LIFO queue
      * @since 1.4
      */
      public synchronized boolean getLifo() {
@@ -1267,24 +1268,22 @@
      * Create an object, and place it into the pool.
      * addObject() is useful for "pre-loading" a pool with idle objects.
      */
-    public void addObject() throws Exception {
+    public synchronized void addObject() throws Exception {
         assertOpen();
         if (_factory == null) {
             throw new IllegalStateException("Cannot add objects without a factory.");
         }
         Object obj = _factory.makeObject();
-        synchronized (this) {
+        try {
+            assertOpen();
+            addObjectToPool(obj, false);
+        } catch (IllegalStateException ex) { // Pool closed
             try {
-                assertOpen();
-                addObjectToPool(obj, false);
-            } catch (IllegalStateException ex) { // Pool closed
-                try {
-                    _factory.destroyObject(obj);
-                } catch (Exception ex2) {
-                    // swallow
-                }
-                throw ex;
+                _factory.destroyObject(obj);
+            } catch (Exception ex2) {
+                // swallow
             }
+            throw ex;
         }
     }
 



Mime
View raw message