Is Jakarta Commons-Pool Object-Safe?

I am using Jakarta commons-pool-1.5.6.jar. I have 2 different pools of the same type (ex: Car). How to prevent object from returning to the pool?

Here is an example:

//CarPool extends BaseObjectPool
CarPool carPoolA =  new CarPool(); 
CarPool carPoolB =  new CarPool();
carPoolB.returnObject(carPoolA.borrowObject());

I would have thought that the pool would manage its content and would not return an external object to it?

Any thought on this? Do I need to manage this myself?

+3
source share
2 answers

I don't think the default implementation has any thing that does what you described (by looking at their API). But you can configure GenericObjectPool to achieve your goal or write logic in your CarPool. Therefore, I assume that ultimately my answer to your question is yes, you will have to deal with it yourself.

+1

1.x. , .

2.x , , . , , , IllegalStateException 2.x.

0

All Articles