You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/02/12 12:03:00 UTC

[jira] [Work logged] (TOMEE-2125) Datasource config: MaxWait, timeBetweenEvictionRunsMillis and MinEvictableIdleTimeMillis are ignored

     [ https://issues.apache.org/jira/browse/TOMEE-2125?focusedWorklogId=551783&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-551783 ]

ASF GitHub Bot logged work on TOMEE-2125:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Feb/21 12:02
            Start Date: 12/Feb/21 12:02
    Worklog Time Spent: 10m 
      Work Description: rzo1 opened a new pull request #762:
URL: https://github.com/apache/tomee/pull/762


   # What does this PR do?
   
   -  custom configured `MaxWait`, `TimeBetweenEvictionRunsMillis` and `MinEvictableIdleTimeMillis` properties for a datasource are **not** ignored when `TomEEDataSourceCreator` is used.
   - adds a unit test to reproduce the behaviour described in TOMEE-2125 (also affects 7.0.x, 7.1.x and 8.0.x - we might need to backport it)
   
   # References
   
   - https://issues.apache.org/jira/browse/TOMEE-2125
   - https://www.mail-archive.com/users@tomee.apache.org/msg17591.html


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 551783)
    Remaining Estimate: 0h
            Time Spent: 10m

> Datasource config: MaxWait, timeBetweenEvictionRunsMillis and MinEvictableIdleTimeMillis are ignored
> ----------------------------------------------------------------------------------------------------
>
>                 Key: TOMEE-2125
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2125
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Core Server
>    Affects Versions: 7.0.6, 7.1.3, 8.0.6
>            Reporter: Sylvain Berthouzoz
>            Assignee: Richard Zowalla
>            Priority: Major
>              Labels: configuration
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> MaxWait Property is ignored because it will always be removed.
> As example, this is my configuration in tomee.xml
> {code:xml}
> <Resource id="database" type="javax.sql.DataSource">
>         JdbcDriver = com.mysql.jdbc.Driver
>         JdbcUrl = jdbc:mysql://localhost:3306/dbname?useSSL=false
>         UserName = username
>         Password = somepw
>         MaxActive = 20
>         MaxIdle = 20
>         MinIdle = 2
>         InitialSize = 2
>         MaxWait = 5000
>         TestOnBorrow = true
>         ValidationQuery = select 1
>         timeBetweenEvictionRuns = 7200000
>         MinEvictableIdleTimeMillis = 7200000
>         TestWhileIdle = true
>     </Resource>
> {code}
> The error is in the file {{openejb-core-7.0.3.jar!\org\apache\openejb\resource\jdbc\DataSourceFactory}} where it looks for values, instead of looking for key (line 356):
> {code:java}
> private static void convert(Properties properties, Duration duration, String key, String oldKey) {
>         properties.remove(key);
>         if(!properties.contains(oldKey)) {
>             properties.remove(oldKey);
>             if(duration != null) {
>                 if(duration.getUnit() == null) {
>                     duration.setUnit(TimeUnit.MILLISECONDS);
>                 }
>                 long milliseconds = TimeUnit.MILLISECONDS.convert(duration.getTime(), duration.getUnit());
>                 properties.put(oldKey, String.valueOf(milliseconds));
>             }
>         }
>     }
> {code}
> {{properties.contains(oldKey)}} should be replaced by {{properties.containsKey(oldKey)}}
> So all properties which uses this convert method are ignored:
> {code:java}
> convert(properties, maxWaitTime, "maxWaitTime", "maxWait");
> convert(properties, timeBetweenEvictionRuns, "timeBetweenEvictionRuns", "timeBetweenEvictionRunsMillis");
> convert(properties, minEvictableIdleTime, "minEvictableIdleTime", "minEvictableIdleTimeMillis");
> {code}
> ----
> *WORKAROUD*
> To avoid that, it is possible to have fake properties in tomee.xml with the ignored property as value (see the ignoreMe properties at the end):
> {code:xml}
>     <Resource id="smclient" type="javax.sql.DataSource">
>         JdbcDriver = com.mysql.jdbc.Driver
>         JdbcUrl = jdbc:mysql://localhost:3306/dbname?useSSL=false
>         UserName = username
>         Password = somepw
>         MaxActive = 20
>         MaxIdle = 20
>         MinIdle = 2
>         InitialSize = 2
>         MaxWait = 5000
>         TestOnBorrow = true
>         ValidationQuery = select 1
>         timeBetweenEvictionRunsMillis = 7200000
>         MinEvictableIdleTimeMillis = 7200000
>         TestWhileIdle = true
>         ignoreMe = maxWait
>         ignoreMe2 = timeBetweenEvictionRunsMillis
>         ignoreMe3 = minEvictableIdleTimeMillis
>     </Resource>
> {code}
> Then the values are correctly set to the datasources (verified with visualvm in the datasource MBean)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)