List:Commits« Previous MessageNext Message »
From:mmatthews Date:February 13 2007 11:13pm
Subject:Connector/J commit: r6319 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java
   branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java
   trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
Log:

    - Fixed BUG#22628 - Driver.getPropertyInfo() throws NullPointerException for 
      URL that only specifies host and/or port.

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2007-02-13 20:25:19 UTC (rev 6318)
+++ branches/branch_5_0/connector-j/CHANGES	2007-02-13 22:13:27 UTC (rev 6319)
@@ -153,6 +153,9 @@
 	  java.util.Date as a java.sql.Timestamp because it's useful to many folks, 
 	  and (2) that behavior will very likely be required for drivers JDBC-post-4.0.
 	  
+    - Fixed BUG#22628 - Driver.getPropertyInfo() throws NullPointerException for 
+      URL that only specifies host and/or port.
+      	  
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java
===================================================================
---
branches/branch_5_0/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java	2007-02-13
20:25:19 UTC (rev 6318)
+++
branches/branch_5_0/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java	2007-02-13
22:13:27 UTC (rev 6319)
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2007 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as
@@ -418,19 +418,6 @@
 		return false;
 	}
 
-	/**
-	 * 
-	 * 
-	 * @param url
-	 *            ...
-	 * @param defaults
-	 *            ...
-	 * 
-	 * @return ...
-	 * 
-	 * @throws java.sql.SQLException
-	 *             ...
-	 */
 	public Properties parseURL(String url, Properties defaults)
 			throws java.sql.SQLException {
 		Properties urlProps = (defaults != null) ? new Properties(defaults)
@@ -508,13 +495,13 @@
 
 		if (slashIndex != -1) {
 			hostStuff = url.substring(0, slashIndex);
-
+			
 			if ((slashIndex + 1) < url.length()) {
 				urlProps.put(DBNAME_PROPERTY_KEY, //$NON-NLS-1$
 						url.substring((slashIndex + 1), url.length()));
 			}
 		} else {
-			return null;
+			hostStuff = url;
 		}
 
 		if ((hostStuff != null) && (hostStuff.length() > 0)) {

Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-02-13
20:25:19 UTC (rev 6318)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-02-13
22:13:27 UTC (rev 6319)
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2007 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as 
@@ -26,6 +26,7 @@
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.DriverPropertyInfo;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
@@ -38,6 +39,7 @@
 import testsuite.BaseTestCase;
 
 import com.mysql.jdbc.Driver;
+import com.mysql.jdbc.NonRegisteringDriver;
 import com.mysql.jdbc.SQLError;
 
 /**
@@ -1636,6 +1638,27 @@
 		}
 	}
 
+	/**
+	 * Fix for BUG#22628 - Driver.getPropertyInfo() throws NullPointerException for URL that
only specifies
+	 * host and/or port.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug22628() throws Exception {
+		DriverPropertyInfo[] dpi = new
NonRegisteringDriver().getPropertyInfo("jdbc:mysql://bogus:9999", 
+				new Properties());
+		
+		boolean foundHost = false;
+		
+		for (int i = 0; i < dpi.length; i++) {
+			if ("bogus:9999".equals(dpi[i].value)) {
+				foundHost = true;
+				break;
+			}
+		}
+		
+		assertTrue(foundHost);
+	}
 
 	private void testAbsenceOfMetadataForQuery(String query) throws Exception {
 		try {

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2007-02-13 20:25:19 UTC (rev 6318)
+++ trunk/connector-j/CHANGES	2007-02-13 22:13:27 UTC (rev 6319)
@@ -152,7 +152,10 @@
 	  false by default, as (1) We already had specific behavior to treat 
 	  java.util.Date as a java.sql.Timestamp because it's useful to many folks, 
 	  and (2) that behavior will very likely be required for drivers JDBC-post-4.0.
-	  	  	  
+
+    - Fixed BUG#22628 - Driver.getPropertyInfo() throws NullPointerException for 
+      URL that only specifies host and/or port.
+      
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: trunk/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java	2007-02-13 20:25:19 UTC
(rev 6318)
+++ trunk/connector-j/src/com/mysql/jdbc/NonRegisteringDriver.java	2007-02-13 22:13:27 UTC
(rev 6319)
@@ -263,8 +263,8 @@
 		}
 
 		try {
-			Connection newConn = com.mysql.jdbc.Connection.getInstance(host(props),
-					port(props), props, database(props), url);
+			Connection newConn = com.mysql.jdbc.Connection.getInstance(
+					host(props), port(props), props, database(props), url);
 
 			return newConn;
 		} catch (SQLException sqlEx) {
@@ -418,19 +418,6 @@
 		return false;
 	}
 
-	/**
-	 * 
-	 * 
-	 * @param url
-	 *            ...
-	 * @param defaults
-	 *            ...
-	 * 
-	 * @return ...
-	 * 
-	 * @throws java.sql.SQLException
-	 *             ...
-	 */
 	public Properties parseURL(String url, Properties defaults)
 			throws java.sql.SQLException {
 		Properties urlProps = (defaults != null) ? new Properties(defaults)
@@ -440,21 +427,22 @@
 			return null;
 		}
 
-		if (!StringUtils.startsWithIgnoreCase(url, "jdbc:mysql://") && 
-				!StringUtils.startsWithIgnoreCase(url, "jdbc:mysql:mxj://")) { //$NON-NLS-1$
+		if (!StringUtils.startsWithIgnoreCase(url, "jdbc:mysql://")
+				&& !StringUtils.startsWithIgnoreCase(url, "jdbc:mysql:mxj://")) {
//$NON-NLS-1$
 
 			return null;
 		}
 
 		int beginningOfSlashes = 13;
-		
+
 		if (StringUtils.startsWithIgnoreCase(url, "jdbc:mysql:mxj://")) {
 			beginningOfSlashes = 17;
-			
-			urlProps.setProperty("socketFactory", 
-				"com.mysql.management.driverlaunched.ServerLauncherSocketFactory");
+
+			urlProps
+					.setProperty("socketFactory",
+							"com.mysql.management.driverlaunched.ServerLauncherSocketFactory");
 		}
-		
+
 		/*
 		 * Parse parameters after the ? in the URL and remove them from the
 		 * original URL.
@@ -494,7 +482,7 @@
 						urlProps.put(parameter, URLDecoder.decode(value));
 					} catch (NoSuchMethodError nsme) {
 						// punt again
-						urlProps.put(parameter,  URLDecoder.decode(value));
+						urlProps.put(parameter, URLDecoder.decode(value));
 					}
 				}
 			}
@@ -514,7 +502,7 @@
 						url.substring((slashIndex + 1), url.length()));
 			}
 		} else {
-			return null;
+			hostStuff = url;
 		}
 
 		if ((hostStuff != null) && (hostStuff.length() > 0)) {
@@ -583,10 +571,11 @@
 									"configs/" + configName + ".properties");
 
 					if (configAsStream == null) {
-						throw SQLError.createSQLException(
-								"Can't find configuration template named '"
-										+ configName + "'",
-								SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);
+						throw SQLError
+								.createSQLException(
+										"Can't find configuration template named '"
+												+ configName + "'",
+										SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);
 					}
 					configProps.load(configAsStream);
 				} catch (IOException ioEx) {

Modified: trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-02-13
20:25:19 UTC (rev 6318)
+++ trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-02-13
22:13:27 UTC (rev 6319)
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2007 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as 
@@ -26,6 +26,7 @@
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.DriverPropertyInfo;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
@@ -38,6 +39,7 @@
 import testsuite.BaseTestCase;
 
 import com.mysql.jdbc.Driver;
+import com.mysql.jdbc.NonRegisteringDriver;
 import com.mysql.jdbc.SQLError;
 
 /**
@@ -1636,7 +1638,28 @@
 		}
 	}
 
-
+	/**
+	 * Fix for BUG#22628 - Driver.getPropertyInfo() throws NullPointerException for URL that
only specifies
+	 * host and/or port.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug22628() throws Exception {
+		DriverPropertyInfo[] dpi = new
NonRegisteringDriver().getPropertyInfo("jdbc:mysql://bogus:9999", 
+				new Properties());
+		
+		boolean foundHost = false;
+		
+		for (int i = 0; i < dpi.length; i++) {
+			if ("bogus:9999".equals(dpi[i].value)) {
+				foundHost = true;
+				break;
+			}
+		}
+		
+		assertTrue(foundHost);
+	}
+	
 	private void testAbsenceOfMetadataForQuery(String query) throws Exception {
 		try {
 			this.pstmt = this.conn.prepareStatement(query);

Thread
Connector/J commit: r6319 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...mmatthews13 Feb