Skip to content

Commit e9dfbe8

Browse files
committed
Fix for Bug#119271 (Bug#38599496), Connector/J fails to accept legacy value zeroDateTimeBehavior=convertToNull on multi-host URLs (failover).
Change-Id: I5ff3fe76ce25cb64a3f94a3ae4287c51c6ca2051
1 parent 36eb175 commit e9dfbe8

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 9.6.0
55

6+
- Fix for Bug#119271 (Bug#38599496), Connector/J fails to accept legacy value zeroDateTimeBehavior=convertToNull on multi-host URLs (failover).
7+
68
- Fix for Bug#119245 (Bug#38599240), Select into fix breaks queries with 'into' in them.
79

810
Version 9.5.0

src/main/core-api/java/com/mysql/cj/conf/ConnectionUrl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ protected void collectProperties(ConnectionUrlParser connStrParser, Properties i
371371
// Collect properties from additional sources.
372372
setupPropertiesTransformer();
373373
expandPropertiesFromConfigFiles(this.properties);
374+
fixProtocolDependencies(this.properties);
375+
replaceLegacyPropertyValues(this.properties);
374376
injectPerTypeProperties(this.properties);
375377
}
376378

src/test/java/com/mysql/cj/ConnectionUrlTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,13 +1196,24 @@ public void testReplaceLegacyPropertyValues() throws Exception {
11961196
connStr.add("jdbc:mysql://127.0.0.1:1234/db?key=value&zeroDateTimeBehavior=convertToNull");
11971197
connStr.add("jdbc:mysql://(port=3306,user=root,password=pwd,zeroDateTimeBehavior=convertToNull)/test");
11981198
connStr.add("jdbc:mysql://address=(port=3306)(user=root)(password=pwd)(zeroDateTimeBehavior=convertToNull)/test");
1199+
connStr.add("jdbc:mysql://onehost:1111,anotherhost:2222/db");
1200+
connStr.add("jdbc:mysql://onehost:1111,anotherhost:2222/db?key=value&zeroDateTimeBehavior=convertToNull");
1201+
connStr.add("jdbc:mysql://(host=onehost,port=1111,key=value,zeroDateTimeBehavior=convertToNull),anotherhost:2222/db");
1202+
connStr.add("jdbc:mysql:loadbalance://onehost:1111,anotherhost:2222/db");
1203+
connStr.add("jdbc:mysql:loadbalance://onehost:1111,anotherhost:2222/db?key=value&zeroDateTimeBehavior=convertToNull");
1204+
connStr.add("jdbc:mysql:loadbalance://(host=onehost,port=1111,key=value,zeroDateTimeBehavior=convertToNull),anotherhost:2222/db");
1205+
connStr.add("jdbc:mysql:replication://onehost:1111,anotherhost:2222/db");
1206+
connStr.add("jdbc:mysql:replication://onehost:1111,anotherhost:2222/db?key=value&zeroDateTimeBehavior=convertToNull");
1207+
connStr.add("jdbc:mysql:replication://(host=onehost,port=1111,key=value,zeroDateTimeBehavior=convertToNull),anotherhost:2222/db");
11991208

12001209
Properties props = new Properties();
12011210
props.setProperty(PropertyKey.zeroDateTimeBehavior.getKeyName(), "convertToNull");
12021211

12031212
for (String cs : connStr) {
12041213
ConnectionUrl connUrl = ConnectionUrl.getConnectionUrlInstance(cs, props);
12051214
assertEquals(ZeroDatetimeBehavior.CONVERT_TO_NULL.name(), connUrl.getMainHost().getProperty(PropertyKey.zeroDateTimeBehavior.getKeyName()));
1215+
assertEquals(ZeroDatetimeBehavior.CONVERT_TO_NULL.name(),
1216+
connUrl.getConnectionArgumentsAsProperties().getProperty(PropertyKey.zeroDateTimeBehavior.getKeyName()));
12061217
}
12071218
}
12081219

src/test/java/testsuite/regression/ConnectionRegressionTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package testsuite.regression;
2222

2323
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
24+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2425
import static org.junit.jupiter.api.Assertions.assertEquals;
2526
import static org.junit.jupiter.api.Assertions.assertFalse;
2627
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -12618,4 +12619,20 @@ public void testBug72036() throws Exception {
1261812619
assertTrue(testXaResA2.isSameRM(testXaResB));
1261912620
}
1262012621

12622+
/**
12623+
* Tests fix for Bug#119271 (Bug#38599496), Connector/J fails to accept legacy value zeroDateTimeBehavior=convertToNull on multi-host URLs (failover).
12624+
*
12625+
* @throws Exception
12626+
*/
12627+
@Test
12628+
void testBug119271() throws Exception {
12629+
Properties props = new Properties();
12630+
props.setProperty(PropertyKey.zeroDateTimeBehavior.getKeyName(), "convertToNull");
12631+
12632+
assertDoesNotThrow(() -> getConnectionWithProps(props).close());
12633+
assertDoesNotThrow(() -> getFailoverConnection(props).close());
12634+
assertDoesNotThrow(() -> getLoadBalancedConnection(props).close());
12635+
assertDoesNotThrow(() -> getSourceReplicaReplicationConnection(props).close());
12636+
}
12637+
1262112638
}

0 commit comments

Comments
 (0)