Avoid reusing/rewriting the DB connection properties. v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 26 Feb 2019 18:19:49 +0100
branchv_0
changeset 236a3ec71fa8e17
parent 235 8ce612cca4d8
child 237 7e08730da258
Avoid reusing/rewriting the DB connection properties.
There was weird random errors while testing connection to multiple DB in parallel when one of them was meta connection to same DB connection.
Two kinds of exception: 1) missing password 2) „Passing DB password as CLI parameter is insecure!“
java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java	Tue Feb 26 17:31:41 2019 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java	Tue Feb 26 18:19:49 2019 +0100
     1.3 @@ -58,6 +58,13 @@
     1.4  	 * @throws java.sql.SQLException
     1.5  	 */
     1.6  	public static Connection jdbcConnect(DatabaseDefinition databaseDefinition, Properties properties) throws SQLException {
     1.7 +		synchronized (properties) {
     1.8 +			/**
     1.9 +			 * Avoid rewriting the properties. Usually, the connection is created only once, but
    1.10 +			 * with --test-connection and with SQL-DK JDBC driver, it might be reused.
    1.11 +			 */
    1.12 +			properties = properties.clone();
    1.13 +		}
    1.14  		if (properties.hasProperty(JDBC_PROPERTY_PASSWORD)) {
    1.15  			log.log(Level.WARNING, "Passing DB password as CLI parameter is insecure!");
    1.16  		}