[
https://issues.apache.org/jira/browse/POOL-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12831981#action_12831981
]
Phil Steitz commented on POOL-157:
----------------------------------
This is the result of the change in pool 1.5 to move factory methods outside of
synchronized scope to avoid deadlocks. The obvious fix for this would be to
move the call to destroy above the factory reassignment. This would, however,
violate the lock order principle above.
I am curious as to the use case for resetting the factory on an active pool.
Why not just close the pool and create a new one with the new factory?
Personally, I have always thought that the factory should be an immutable
property of the pool. I am interested in the understanding the use case.
I propose to resolve this by
* deprecating the setter - to be removed in 2.0
* adding private destroy(PoolableObjectFactory, Collection) and passing it the
old factory
> GenericObjectPool.setFactory(...) does not destroy idle pool objects with
> their original factory object.
> --------------------------------------------------------------------------------------------------------
>
> Key: POOL-157
> URL: https://issues.apache.org/jira/browse/POOL-157
> Project: Commons Pool
> Issue Type: Bug
> Reporter: David Hu
> Priority: Minor
>
> When setting a new object factory, the existing idle poolable objects are not
> destroyed by the same factory that created them.
> 1453 public void setFactory(PoolableObjectFactory factory) throws
> IllegalStateException {
> 1454 List toDestroy = new ArrayList();
> 1455 synchronized (this) {
> 1456 assertOpen();
> 1457 if(0 < getNumActive()) {
> 1458 throw new IllegalStateException("Objects are already
> active");
> 1459 } else {
> 1460 toDestroy.addAll(_pool);
> 1461 _numInternalProcessing = _numInternalProcessing +
> _pool._size;
> 1462 _pool.clear();
> 1463 }
> 1464 _factory = factory;
> 1465 }
> 1466 destroy(toDestroy); // <----- indirectly calls
> _factory.destroy(...) when _factory has already been replaced by the new
> factory.
> 1467 }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.