[CONJ-780] Logic error in implementation of OSGi DataSourceFactory (MariaDbDataSourceFactory) Created: 2020-04-08  Updated: 2020-06-22  Resolved: 2020-06-22

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.6.0
Fix Version/s: 2.6.1

Type: Bug Priority: Minor
Reporter: Domagoj Cosic Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

There is the same logic error in all three factory methods in the if clause condition:

    if (props != null
        || props.containsKey(JDBC_MIN_POOL_SIZE)
        || props.containsKey(JDBC_MAX_POOL_SIZE)
        || props.containsKey(JDBC_MAX_IDLE_TIME)) {
      return createPoolDataSource(props);
    } else {
      return createBasicDataSource(props);
    }

"Else" clause can presently never be reached, as even in the case of props==null, the second term in the condition causes a NullPointerException.

Presumably, the condition should have looked like:

props != null &&
        (props.containsKey(JDBC_MIN_POOL_SIZE)
        || props.containsKey(JDBC_MAX_POOL_SIZE)
        || props.containsKey(JDBC_MAX_IDLE_TIME))



 Comments   
Comment by Diego Dupin [ 2020-06-22 ]

done with https://github.com/mariadb-corporation/mariadb-connector-j/commit/0e6dc646d60da1d4800efa3412ea806b0b3a03c8

Generated at Thu Feb 08 03:18:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.