Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void configureCloudSqlProperties(HikariConfig config, String jdbcUrl) {
}

config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.postgres.SocketFactory");
config.addDataSourceProperty("unixSocketPath", instanceUnixSocket);
config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE");
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable instanceUnixSocket (line 202) is still being used but is now misleading since the code uses TCP connections with ipTypes instead of Unix sockets. The variable should be renamed to reflect its current purpose of identifying the Cloud SQL instance path. Additionally, this change from unixSocketPath to ipTypes will break existing tests in DataSourceConfigTest.java (lines 97 and 123) that assert the presence of unixSocketPath in data source properties. The tests need to be updated to check for ipTypes with value "PUBLIC,PRIVATE" instead.

Copilot uses AI. Check for mistakes.
String cloudSqlInstance = extractCloudSqlInstance(instanceUnixSocket);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After switching from unixSocketPath to ipTypes for TCP connections, the variable name instanceUnixSocket at line 209 is misleading. While the logic correctly extracts the Cloud SQL instance identifier from the path, the variable name suggests Unix socket usage. Consider renaming to instancePath or cloudSqlHostPath to better reflect its purpose of identifying the Cloud SQL instance regardless of connection type.

Copilot uses AI. Check for mistakes.
if (isNotBlank(cloudSqlInstance)) {
config.addDataSourceProperty("cloudSqlInstance", cloudSqlInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ void hikariConfig_ShouldNormalizeCloudSqlSocketStyleDatabaseUrl() throws Excepti
+ "&password=redacted-password");
assertThat(result.getDataSourceProperties())
.containsEntry("socketFactory", "com.google.cloud.sql.postgres.SocketFactory")
.containsEntry("unixSocketPath", "/cloudsql/project-id:region:instance-id")
.containsEntry("ipTypes", "PUBLIC,PRIVATE")
.containsEntry("cloudSqlInstance", "project-id:region:instance-id")
.doesNotContainKey("unixSocketPath")
.doesNotContainKey("cloudSqlRefreshStrategy");
}

Expand All @@ -120,8 +121,9 @@ void hikariConfig_ShouldSetCloudSqlRefreshStrategyOnCloudRunInSocketMode() throw

assertThat(result.getDataSourceProperties())
.containsEntry("socketFactory", "com.google.cloud.sql.postgres.SocketFactory")
.containsEntry("unixSocketPath", "/cloudsql/project-id:region:instance-id")
.containsEntry("ipTypes", "PUBLIC,PRIVATE")
.containsEntry("cloudSqlInstance", "project-id:region:instance-id")
.doesNotContainKey("unixSocketPath")
.containsEntry("cloudSqlRefreshStrategy", "lazy");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object DatabaseFactory {
}

hikariConfig.addDataSourceProperty("socketFactory", CLOUD_SQL_SOCKET_FACTORY)
hikariConfig.addDataSourceProperty("unixSocketPath", config.host)
hikariConfig.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE")
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name unixSocketPath in the extractCloudSqlInstance function (line 91) is misleading after this change. Since the code now uses TCP connections with ipTypes instead of Unix sockets, this parameter should be renamed to something more accurate like cloudSqlHostPath or instancePath to reflect that it contains the Cloud SQL instance identifier path. Additionally, this change will break the test in DatabaseFactoryTest.kt (line 70) that asserts the presence of unixSocketPath in data source properties. The test needs to be updated to check for ipTypes with value "PUBLIC,PRIVATE" instead.

Copilot uses AI. Check for mistakes.
val cloudSqlInstance = extractCloudSqlInstance(config.host)
if (cloudSqlInstance != null) {
hikariConfig.addDataSourceProperty("cloudSqlInstance", cloudSqlInstance)
Expand Down