commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hajratwala, Nayan (N.)" <>
Subject [pool] Proposal to add invalidateObject(Object obj) to ObjectPool
Date Mon, 30 Sep 2002 17:15:20 GMT
Folks ... I have not received any feedback on my proposal below... is it a
terrible idea?

Should i just go ahead and make mods & submit a patch?

show me a little love here... =)

From: Hajratwala, Nayan (N.) 
Subject: [PROPOSAL - POOL API] add invalidateObject(Object obj) to
Date: Wed, 25 Sep 2002 13:17:38 -0700 

Within commons-pool, I'd like to propose adding the following method to the

        public void invalidateObject(Object obj);

This would be used to address the situation in which you borrow an object
from the 
pool, and then upon use, discover that it is invalid, at which point you
need to get 
another one.


        ObjectPool pool = new GenericObjectPool(...);

        boolean success = false;

        while (!success) {

                try {
                        SomeConnection sc =

                        success = true;
                catch (SomeConnectionException e) {

Why not use PoolableObjectFactory's "validateObject" method you ask?

Well, that requires testing the Object either before or after you use it,
results in an extra call on the object EVERY time you borrow it (or return
it).  This 
is a problem when the operation required to do the testing is expensive.

I'll be happy to take a crack at an implementation if people think this is a
good idea.

Does this seem like a good idea, or are there other ways to address this


- Nayan Hajratwala
- Chikli Consulting LLC

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message