Bug #119271 Connector/J fails to accept legacy value zeroDateTimeBehavior=convertToNull on multi-host URLs (failover), but works on
Submitted: 30 Oct 11:14 Modified: 30 Oct 20:02
Reporter: Wu Zhengyi Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:All OS:Any
Assigned to: Filipe Silva CPU Architecture:Any
Tags: backward-compatibility, failover, multi-host, properties, zeroDateTimeBehavior

[30 Oct 11:14] Wu Zhengyi
Description:
When using a multi-host JDBC URL (failover) with the legacy property value zeroDateTimeBehavior=convertToNull, the driver throws an exception stating the only acceptable values are CONVERT_TO_NULL, EXCEPTION, or ROUND. The same property/value works with a single-host URL.
Root cause:
Legacy value translation is applied only per-host in fixHostInfo() via replaceLegacyPropertyValues(hostProps).
In the failover path, FailoverConnectionProxy initializes properties from ConnectionUrl.getConnectionArgumentsAsProperties(), which returns the global properties map (this.properties) that has not been passed through replaceLegacyPropertyValues.
As a result, convertToNull is not normalized to CONVERT_TO_NULL and enum parsing fails in EnumPropertyDefinition.
Impact:
Backward-compatible URLs that rely on convertToNull fail in multi-host scenarios, but succeed in single-host scenarios, creating inconsistent behavior.
Exception (abridged):
com.mysql.cj.exceptions.CJException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.

How to repeat:
Use a JDBC URL with two hosts and legacy value:
jdbc:mysql://host1:3306,host2:3306?useSSL=false&zeroDateTimeBehavior=convertToNull
Attempt to connect (e.g., via DriverManager.getConnection).
Observe: connection fails with WrongArgumentException as above.
Control:
Using a single host URL with the same parameters succeeds:
jdbc:mysql://host1:3306?useSSL=false&zeroDateTimeBehavior=convertToNull

Suggested fix:
Normalize legacy property values in the global properties map, not only in per-host maps.
Concrete change:
In com.mysql.cj.conf.ConnectionUrl.collectProperties(...), after expanding and injecting properties, call:
fixProtocolDependencies(this.properties) [optional but consistent], and
replaceLegacyPropertyValues(this.properties)
so that getConnectionArgumentsAsProperties() returns already-normalized values used by FailoverConnectionProxy and other multi-host connection proxies.
Rationale:
Single-host paths use HostInfo built through fixHostInfo(), which already calls replaceLegacyPropertyValues(hostProps).
Multi-host paths use global properties; normalizing them ensures parity between single- and multi-host behaviors.
Compatibility:
Safe; only broadens acceptance of legacy values in global properties, maintaining existing behavior for per-host properties.
[30 Oct 20:02] Filipe Silva
Thank you for your interest in MySQL Connector/J and for taking the time to file this report.

Verified as described.