commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15339] New: - StackObjectPool needs to ensure available objects in pool are unique
Date Thu, 12 Dec 2002 23:00:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15339>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15339

StackObjectPool needs to ensure available objects in pool are unique

           Summary: StackObjectPool needs to ensure available objects in
                    pool are unique
           Product: Commons
           Version: 1.0.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Pool
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: edecosta@mathworks.com


java.util.Stack is not a Set and thus does not guarantee a unique set of objects
to be available in the pool.  In the unfortunate circumstance that returnObject
is called twice on the same object, this will make two references to the same
resource available in the pool.  My simple work-around is shown in the diff
below.

--- StackObjectPool.java        Wed May  1 02:02:34 2002
+++
/home/edecosta/work/komodo/src/org/apache/commons/pool/impl/StackObjectPool.java   
Thu Dec 12 17:50:17 2002
@@ -191,6 +191,8 @@
             if(_pool.size() >= _maxSleeping) {
                 shouldDestroy = true;
             } else if(success) {
+                if (_pool.contains(obj)) 
+                    throw new IllegalStateException("Pool already contains this
object!");
                 _pool.push(obj);
             }
             notifyAll(); // _numActive has changed

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


Mime
View raw message