Skip to content

Commit 5940440

Browse files
committed
Fix for Bug#107094 (Bug#34104230), NullPointerException when calling equals with null on MultiHostConnectionProxy.
Change-Id: I47e30464eda0f86a347ab43efc67daef32ad2e81
1 parent cbc9478 commit 5940440

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGES

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

44
Version 9.5.0
55

6+
- Fix for Bug#107094 (Bug#34104230), NullPointerException when calling equals with null on MultiHostConnectionProxy.
7+
68
- Fix for Bug#107543 (Bug#34464351), Cannot execute a SELECT statement that writes to an OUTFILE.
79

810
- Fix for Bug#17881458, BEHAVIOR OF SETBINARYSTREAM() METHOD IS DIFFERENT WHEN USESERVERPREPSTMTS=TRUE.

src/main/user-impl/java/com/mysql/cj/jdbc/ha/MultiHostConnectionProxy.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
482482
}
483483

484484
if (METHOD_EQUALS.equals(methodName)) {
485+
if (args[0] == null) {
486+
return false;
487+
}
485488
// Let args[0] "unwrap" to its InvocationHandler if it is a proxy.
486489
return args[0].equals(this);
487490
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12447,4 +12447,30 @@ void testBug44791() throws Exception {
1244712447
} while (useSPS = !useSPS);
1244812448
}
1244912449

12450+
/**
12451+
* Tests fix for Bug#107094 (Bug#34104230), NullPointerException when calling equals with null on MultiHostConnectionProxy.
12452+
*
12453+
* @throws Exception
12454+
*/
12455+
@Test
12456+
void testBug107094() throws Exception {
12457+
assertTrue(this.conn.equals(this.conn));
12458+
assertFalse(this.conn.equals(null));
12459+
12460+
try (Connection testConn = getFailoverConnection()) {
12461+
assertTrue(testConn.equals(testConn));
12462+
assertFalse(testConn.equals(null));
12463+
}
12464+
12465+
try (Connection testConn = getLoadBalancedConnection()) {
12466+
assertTrue(testConn.equals(testConn));
12467+
assertFalse(testConn.equals(null));
12468+
}
12469+
12470+
try (Connection testConn = getSourceReplicaReplicationConnection()) {
12471+
assertTrue(testConn.equals(testConn));
12472+
assertFalse(testConn.equals(null));
12473+
}
12474+
}
12475+
1245012476
}

0 commit comments

Comments
 (0)