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 16987] - race condition in PoolableConnection.close()
Date Sat, 12 Apr 2003 01:59:18 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=16987>.
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=16987

race condition in PoolableConnection.close()





------- Additional Comments From mohankishore@yahoo.com  2003-04-12 01:59 -------
I didnt quite get the part about why we cant make the whole method 
synchronized. Am appending two methods - wont this work?

PoolableConnection:
    synchronized public void close() throws SQLException {
        if(isClosed()) {
            // no-op
        } else {
            try {
                _pool.returnObject(this);
            } catch(Exception e) {
                // no-op
            }
        }
    }


GenericObjectPool:
    synchronized public void returnObject(Object obj) throws Exception {
        assertOpen();
        boolean shouldDestroy = false;
        if(_testOnReturn && !(_factory.validateObject(obj))) {
            shouldDestroy = true;
        }
        if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) {
            shouldDestroy = true;
        }
        try {
            _factory.passivateObject(obj);
        } catch(Exception e) {
            shouldDestroy = true;
        }
        
        if(!shouldDestroy) {
            _pool.addFirst(new ObjectTimestampPair(obj));
        } else {
            try {
                _factory.destroyObject(obj);
            } catch(Exception e) {
                // ignored
            }
        }
        _numActive--;
        notifyAll(); // _numActive has changed
    }

Am also going to attach the diff for comparision...

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