You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mark Symons (JIRA)" <ji...@apache.org> on 2016/05/20 10:50:12 UTC

[jira] [Commented] (DBCP-334) BasicDataSource does not consider the method "setSoftMinEvictableIdleTimeMillis" of CommonsPool.GenericObjectPool

    [ https://issues.apache.org/jira/browse/DBCP-334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15293164#comment-15293164 ] 

Mark Symons commented on DBCP-334:
----------------------------------

This issue was closed over 5 years ago... but the versions in which the defect was fixed (1.3.1 & 1.4.1) have yet to be released.  Or is there a missing fix version on this JIRA issue.  2.0 perhaps?

Note that the same problem afflicts a couple of other issues as well:

DBCP-371
DBCP-421

The latter is a duplicate of DBCP-330 but the affected versions differ between the two issues.

> BasicDataSource does not consider the method "setSoftMinEvictableIdleTimeMillis" of CommonsPool.GenericObjectPool
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: DBCP-334
>                 URL: https://issues.apache.org/jira/browse/DBCP-334
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.2.1, 1.2.2, 1.3, 1.4
>            Reporter: Alberto Mozzone
>            Priority: Critical
>             Fix For: 1.3.1, 1.4.1
>
>
> The BasicDataSource should have the "softMinEvictableIdleTimeMillis" (get and set) as the GenericObjectPool, to avoid destroying idle connections below the "minIdle" value. In this case, connections are dropped and immediately recreated with no reason. The "minEvictableIdleTimeMillis" should not be considered because there are ways to validate idle connections before they are used.
> The class should have these lines of code, besides those existing:
> // property
> 	private long softMinEvictableIdleTimeMillis = GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
> // getter
> 	/**
> 	 * Returns the {@link #softMinEvictableIdleTimeMillis} property.
> 	 * @return the value of the {@link #softMinEvictableIdleTimeMillis} property
> 	 * @see #softMinEvictableIdleTimeMillis
> 	 */
> 	public synchronized long getSoftMinEvictableIdleTimeMillis() {
> 		return softMinEvictableIdleTimeMillis;
> 	}
> // setter
> 	/**
> 	 * Sets the {@link #softMinEvictableIdleTimeMillis} property.
> 	 * @param softMinEvictableIdleTimeMillis the minimum amount of time an object
> 	 * may sit idle in the pool 
> 	 * @see #softMinEvictableIdleTimeMillis
> 	 */
> 	public synchronized void setSoftMinEvictableIdleTimeMillis(final long softMinEvictableIdleTimeMillis) {
> 		this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
> 		if (connectionPool != null) {
> 			connectionPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
> 		}
> 	}
> // creator of the pool
> 	@Override protected void createConnectionPool() {
> 		super.createConnectionPool();
> 		connectionPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
> 	}
> I implemented myself a "NotSoBasicDataSource" class, inheriting from "BasicDataSource" and used it in a single test. It worked: idle connections do not decrease under (and re-grow to) "minIdle".
> Please, consider this feature, because it can save resources.
> I don't know what is the behavior of the Tomcat DBCP, but it seems to me it has the same problem.
> I'm waiting your opinions.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)