From: Date: June 16 2006 7:55pm Subject: Connector/J commit: r5399 - in branches: branch_5_0/connector-j branch_5_0/connector-j/src/com/mysql/jdbc branch_5_1/connector-j branch_5_1/connector-j/src/com/mysql/jdbc List-Archive: http://lists.mysql.com/commits/7778 X-Bug: 19169 Message-Id: <200606161755.k5GHtGAx010346@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_0/connector-j/CHANGES branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java branches/branch_5_1/connector-j/CHANGES branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionProperties.java Log: Fixed BUG#19169 - ConnectionProperties (and thus some subclasses) are not serializable, even though some J2EE containers expect them to be. Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2006-06-16 17:38:04 UTC (rev 5398) +++ branches/branch_5_0/connector-j/CHANGES 2006-06-16 17:55:13 UTC (rev 5399) @@ -14,6 +14,10 @@ of the "language" server variable to the character set that is used for error messages. + - Fixed BUG#19169 - ConnectionProperties (and thus some + subclasses) are not serializable, even though some J2EE containers + expect them to be. + 12-23-05 - Version 5.0.0-beta - XADataSource implemented (ported from 3.2 branch which won't be Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:38:04 UTC (rev 5398) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:55:13 UTC (rev 5399) @@ -28,6 +28,7 @@ import com.mysql.jdbc.log.Log; import com.mysql.jdbc.log.StandardLogger; +import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.sql.DriverPropertyInfo; @@ -52,8 +53,14 @@ * @version $Id: ConnectionProperties.java,v 1.1.2.2 2005/05/17 14:58:56 * mmatthews Exp $ */ -public class ConnectionProperties { - class BooleanConnectionProperty extends ConnectionProperty { +public class ConnectionProperties implements Serializable { + + private static final long serialVersionUID = 4257801713007640580L; + + class BooleanConnectionProperty extends ConnectionProperty implements Serializable { + + private static final long serialVersionUID = 2540132501709159404L; + /** * DOCUMENT ME! * @@ -117,7 +124,7 @@ } } - abstract class ConnectionProperty extends DriverPropertyInfo { + abstract class ConnectionProperty implements Serializable { String[] allowableValues; String categoryName; @@ -136,12 +143,17 @@ Object valueAsObject; + boolean required; + + String description; + + public ConnectionProperty() {} + ConnectionProperty(String propertyNameToSet, Object defaultValueToSet, String[] allowableValuesToSet, int lowerBoundToSet, int upperBoundToSet, String descriptionToSet, String sinceVersionToSet, String category, int orderInCategory) { - super(propertyNameToSet, null); - + this.description = descriptionToSet; this.propertyName = propertyNameToSet; this.defaultValue = defaultValueToSet; @@ -242,15 +254,16 @@ } } - /** - * Synchronizes the state of a ConnectionProperty so that it can be - * exposed as a DriverPropertyInfo instance. - */ - void syncDriverPropertyInfo() { - this.choices = getAllowableValues(); - this.value = (this.valueAsObject != null) ? this.valueAsObject - .toString() : null; + DriverPropertyInfo getAsDriverPropertyInfo() { + DriverPropertyInfo dpi = new DriverPropertyInfo(this.propertyName, null); + dpi.choices = getAllowableValues(); + dpi.value = (this.valueAsObject != null) ? this.valueAsObject.toString() : null; + dpi.required = this.required; + dpi.description = this.description; + + return dpi; } + void validateStringValues(String valueToValidate) throws SQLException { String[] validateAgainst = getAllowableValues(); @@ -303,7 +316,10 @@ } } - class IntegerConnectionProperty extends ConnectionProperty { + class IntegerConnectionProperty extends ConnectionProperty implements Serializable { + + private static final long serialVersionUID = -8147538210820248187L; + int multiplier = 1; IntegerConnectionProperty(String propertyNameToSet, @@ -408,8 +424,10 @@ } } - class MemorySizeConnectionProperty extends IntegerConnectionProperty { + class MemorySizeConnectionProperty extends IntegerConnectionProperty implements Serializable { + private static final long serialVersionUID = 7351065128998572656L; + MemorySizeConnectionProperty(String propertyNameToSet, int defaultValueToSet, int lowerBoundToSet, int upperBoundToSet, String descriptionToSet, @@ -461,7 +479,10 @@ } } - class StringConnectionProperty extends ConnectionProperty { + class StringConnectionProperty extends ConnectionProperty implements Serializable { + + private static final long serialVersionUID = 5432127962785948272L; + StringConnectionProperty(String propertyNameToSet, String defaultValueToSet, String descriptionToSet, String sinceVersionToSet, String category, int orderInCategory) { @@ -1402,8 +1423,8 @@ propToExpose.initializeFrom(info); } - propToExpose.syncDriverPropertyInfo(); - driverProperties[i] = propToExpose; + + driverProperties[i] = propToExpose.getAsDriverPropertyInfo(); } catch (IllegalAccessException iae) { throw SQLError.createSQLException("Internal properties failure", SQLError.SQL_STATE_GENERAL_ERROR); @@ -1517,8 +1538,7 @@ while (orderedIter.hasNext()) { ConnectionProperty propToGet = (ConnectionProperty) orderedIter .next(); - propToGet.syncDriverPropertyInfo(); - + xmlBuf.append("\n