List:Commits« Previous MessageNext Message »
From:mmatthews Date:April 3 2008 10:28pm
Subject:Connector/J commit: r6769 - in branches/branch_5_1: . src/com/mysql/jdbc/jdbc2/optional src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_1/CHANGES
   branches/branch_5_1/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java
   branches/branch_5_1/src/testsuite/regression/DataSourceRegressionTest.java
Log:
Fixed BUG#35810 - Properties set in URLs and then passed to DataSources via setUrl() 
	  did not take effect in certain circumstances. This also fixes related bugs BUG#13261
and
	  BUG#35753.

Modified: branches/branch_5_1/CHANGES
===================================================================
--- branches/branch_5_1/CHANGES	2008-04-03 18:03:10 UTC (rev 6768)
+++ branches/branch_5_1/CHANGES	2008-04-03 20:28:35 UTC (rev 6769)
@@ -26,6 +26,10 @@
 	  JDBC specification itself, but the test makes sure that our implementation is
 	  at least consistent.
 	    
+	- Fixed BUG#35810 - Properties set in URLs and then passed to DataSources via setUrl() 
+	  did not take effect in certain circumstances. This also fixes related bugs BUG#13261
and
+	  BUG#35753.
+	  
 03-06-08 - Version 5.1.6
 
     - JDBC-4.0-ized XAConnections and datasources.

Modified: branches/branch_5_1/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java	2008-04-03
18:03:10 UTC (rev 6768)
+++ branches/branch_5_1/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java	2008-04-03
20:28:35 UTC (rev 6769)
@@ -27,6 +27,7 @@
 import java.io.PrintWriter;
 import java.io.Serializable;
 import java.sql.SQLException;
+import java.util.Iterator;
 import java.util.Properties;
 
 import javax.naming.NamingException;
@@ -419,6 +420,23 @@
 			jdbcUrlToUse = this.url;
 		}
 
+		//
+		// URL should take precedence over properties
+		//
+		
+		Properties urlProps = mysqlDriver.parseURL(jdbcUrlToUse, null);
+		urlProps.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
+		urlProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
+		urlProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
+		
+		Iterator keys = urlProps.keySet().iterator();
+		
+		while (keys.hasNext()) {
+			String key = (String)keys.next();
+			
+			props.setProperty(key, urlProps.getProperty(key));
+		}
+		
 		return mysqlDriver.connect(jdbcUrlToUse, props);
 	}
 //

Modified: branches/branch_5_1/src/testsuite/regression/DataSourceRegressionTest.java
===================================================================
--- branches/branch_5_1/src/testsuite/regression/DataSourceRegressionTest.java	2008-04-03
18:03:10 UTC (rev 6768)
+++ branches/branch_5_1/src/testsuite/regression/DataSourceRegressionTest.java	2008-04-03
20:28:35 UTC (rev 6769)
@@ -51,6 +51,7 @@
 import testsuite.BaseTestCase;
 import testsuite.simple.DataSourceTest;
 
+import com.mysql.jdbc.ConnectionProperties;
 import com.mysql.jdbc.NonRegisteringDriver;
 import com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker;
 import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
@@ -490,4 +491,25 @@
 		assertNotNull(pc.getConnection().prepareStatement("SELECT 1",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
 		assertNotNull(pc.getConnection().prepareStatement("SELECT 1",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT));
 	}
+
+	public void testBug35810() throws Exception {
+		int defaultConnectTimeout = ((ConnectionProperties) this.conn).getConnectTimeout();
+		int nonDefaultConnectTimeout = defaultConnectTimeout + 1000 * 2;
+		MysqlConnectionPoolDataSource cpds = new MysqlConnectionPoolDataSource();
+		String dsUrl = BaseTestCase.dbUrl;
+		if (dsUrl.indexOf("?") == -1) {
+			dsUrl += "?";
+		} else {
+			dsUrl += "&";
+		}
+		
+		dsUrl += "connectTimeout=" + nonDefaultConnectTimeout;
+		cpds.setUrl(dsUrl);
+		
+		Connection dsConn = cpds.getPooledConnection().getConnection();
+		int configuredConnectTimeout = ((ConnectionProperties) dsConn).getConnectTimeout();
+		
+		assertEquals("Connect timeout spec'd by URL didn't take", nonDefaultConnectTimeout,
configuredConnectTimeout);
+		assertFalse("Connect timeout spec'd by URL didn't take", defaultConnectTimeout ==
configuredConnectTimeout);
+	}
 }

Thread
Connector/J commit: r6769 - in branches/branch_5_1: . src/com/mysql/jdbc/jdbc2/optional src/testsuite/regressionmmatthews3 Apr