[
https://issues.apache.org/jira/browse/POOL-212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13252785#comment-13252785
]
Sergejs Melderis commented on POOL-212:
---------------------------------------
Here is what I did in my application.
@Override
public void setMaxIdle(int maxIdle) {
int minIdle = getMinIdle();
if (maxIdle < minIdle) {
super.setMinIdle(maxIdle);
}
super.setMaxIdle(maxIdle);
}
@Override
public void setMinIdle(int minIdle) {
int maxIdle = super.getMaxIdle();
if (maxIdle < minIdle) {
super.setMaxIdle(minIdle);
}
super.setMinIdle(minIdle);
}
If client intentions are correct, meaning minIdle <= maxIdle the order doesn't
matter.But if client calls setters
with minIdle > maxIdle then, yes, it may end up in different configuration
depending on the order of calls.
> GenericObjectPool allows maxIdle < minIdle
> ------------------------------------------
>
> Key: POOL-212
> URL: https://issues.apache.org/jira/browse/POOL-212
> Project: Commons Pool
> Issue Type: Bug
> Affects Versions: 1.4
> Reporter: Sergejs Melderis
> Priority: Minor
> Fix For: 2.0
>
>
> GenericObjectPool allows any values for minIdle and maxIdle, and performs no
> validation on those values.
> It allows maxIdle to be less than minIdle, and that creates weird behavior
> during eviction.
> After each eviction the Evictor thread calls ensureMinIdle() method which
> adds objects the pool using addObjectToPool() to make sure there at least
> minIdle objects in the pool.addObjectToPool() on another hand makes sure that
> there no more then maxIdle objects in the pool, and immediately destroys the
> newly created object.
> In my application we had minIdle configured to 100, but maxIdle wasn't
> configured and used the default value which is 8, and each eviction would
> create and destroy a bunch of objects.
> This issue can be fixed by adding checks in setMinIdle and setMaxIdle, or by
> adding maxIdle variable to the formula used in calculateDevicit() method.
> We use version 1.4, but I also tested it on latest 1.6 and observed the same
> behavior.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira