Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 407a0d8

Browse files
committed
chore: use Joiner and copy of map when setting properties
1 parent 290d317 commit 407a0d8

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,6 @@ static String parseUriProperty(String uri, String property) {
665665
* @throws BigQueryJdbcRuntimeException if an unknown property is found or the URL is malformed.
666666
*/
667667
static Map<String, String> parseUrl(String url) {
668-
if (url == null) {
669-
return Collections.emptyMap();
670-
}
671668
return PARSE_CACHE.computeIfAbsent(url, BigQueryJdbcUrlUtility::parseUrlInternal);
672669
}
673670

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/DataSource.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.google.cloud.bigquery.jdbc;
1818

1919
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
20+
import com.google.common.base.Joiner;
21+
import com.google.common.collect.ImmutableMap;
2022
import java.io.PrintWriter;
2123
import java.sql.Connection;
2224
import java.sql.DriverManager;
@@ -351,14 +353,7 @@ private String serializeMap(Map<String, String> map) {
351353
if (map == null || map.isEmpty()) {
352354
return "";
353355
}
354-
StringBuilder sb = new StringBuilder();
355-
for (Map.Entry<String, String> entry : map.entrySet()) {
356-
if (sb.length() > 0) {
357-
sb.append(",");
358-
}
359-
sb.append(entry.getKey()).append("=").append(entry.getValue());
360-
}
361-
return sb.toString();
356+
return Joiner.on(",").withKeyValueSeparator("=").join(map);
362357
}
363358

364359
@Override
@@ -451,7 +446,7 @@ public String getKmsKeyName() {
451446
}
452447

453448
public void setQueryProperties(Map<String, String> queryProperties) {
454-
this.queryProperties = queryProperties;
449+
this.queryProperties = queryProperties == null ? null : ImmutableMap.copyOf(queryProperties);
455450
}
456451

457452
public Map<String, String> getQueryProperties() {
@@ -711,7 +706,7 @@ public Map<String, String> getLabels() {
711706
}
712707

713708
public void setLabels(Map<String, String> labels) {
714-
this.labels = labels;
709+
this.labels = labels == null ? null : ImmutableMap.copyOf(labels);
715710
}
716711

717712
public String getRequestReason() {

0 commit comments

Comments
 (0)