Skip to content

Commit 56eb874

Browse files
committed
Fixed NPE with SslMode.TUNNEL Usage
Motivation: A NPE was identified when utilizing `SslMode.TUNNEL`, introduced by PR #204. The issue arises when `ConnectionContext#isMariaDb` is invoked from `SslBridgeHandler#isTls13Enabled`, leading to an NPE due to the ConnectionContext not being initialized at that time. Modification: We have updated ConnectionContext#isMariaDb to return false if the context has not been initialized, preventing the NPE. (Mainly to restore previous behavior) Result: This change addresses the NPE issue, ensuring stability when `SslMode.TUNNEL` is selected. It resolves the problem reported in GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#1828
1 parent 6982acc commit 56eb874

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/io/asyncer/r2dbc/mysql/Capability.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class Capability {
2727
/**
2828
* If UNSET, the server supports the MariaDB protocol and statements.
2929
*/
30-
private static final long CLIENT_MYSQL = 1L;
30+
static final long CLIENT_MYSQL = 1L;
3131

3232
/**
3333
* Use found/touched rows instead of changed rows for affected rows. Should enable it by default.

src/main/java/io/asyncer/r2dbc/mysql/ConnectionContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public final class ConnectionContext implements CodecContext {
3737

3838
private static final ServerVersion NONE_VERSION = ServerVersion.create(0, 0, 0);
3939

40+
private static final Capability NONE_CAPABILITY = Capability.of(Capability.CLIENT_MYSQL);
41+
4042
private volatile int connectionId = -1;
4143

4244
private volatile ServerVersion serverVersion = NONE_VERSION;
@@ -57,7 +59,7 @@ public final class ConnectionContext implements CodecContext {
5759
*/
5860
private volatile short serverStatuses = ServerStatuses.AUTO_COMMIT;
5961

60-
private volatile Capability capability = null;
62+
private volatile Capability capability = NONE_CAPABILITY;
6163

6264
ConnectionContext(ZeroDateOption zeroDateOption, @Nullable Path localInfilePath,
6365
int localInfileBufferSize, @Nullable ZoneId serverZoneId) {

0 commit comments

Comments
 (0)