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

Commit 2d2da43

Browse files
committed
refactor(jdbc): clean up redundant property lookups in UrlUtility
1 parent 2200d63 commit 2d2da43

7 files changed

Lines changed: 23 additions & 769 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ class BigQueryPooledConnection implements PooledConnection {
3939
BigQueryPooledConnection(Connection bqConnection) {
4040
this.bqConnection = bqConnection;
4141
this.id = UUID.randomUUID().toString();
42-
String connectionUrl = ((BigQueryConnection) bqConnection).getConnectionUrl();
43-
if (connectionUrl != null && !connectionUrl.isEmpty()) {
44-
this.listenerPoolSize =
45-
BigQueryJdbcUrlUtility.parseListenerPoolSize(connectionUrl, this.toString());
42+
if (bqConnection instanceof BigQueryConnection) {
43+
this.listenerPoolSize = ((BigQueryConnection) bqConnection).getListenerPoolSize();
4644
}
4745
if (getListenerPoolSize() > 0L) {
4846
listeners = new LinkedBlockingDeque<>(getListenerPoolSize().intValue());

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public PooledConnection getPooledConnection() throws SQLException {
4040
throw new BigQueryJdbcRuntimeException(
4141
"Cannot get pooled connection: unable to get underlying physical connection");
4242
}
43-
String connectionURl = ((BigQueryConnection) bqConnection).getConnectionUrl();
44-
Long connectionPoolSize =
45-
BigQueryJdbcUrlUtility.parseConnectionPoolSize(connectionURl, this.toString());
43+
Long connectionPoolSize = this.getConnectionPoolSize();
4644
if (connectionPoolManager == null) {
4745
connectionPoolManager = new PooledConnectionListener(connectionPoolSize);
4846
}

google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtilityTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public void testInvalidTokenUriForAuthType0() {
9090
+ "EndpointOverrides=OAuth2=brokenuri{};";
9191
Map<String, String> oauthProperties =
9292
BigQueryJdbcOAuthUtility.parseOAuthProperties(connectionString, null);
93-
Map<String, String> overrideProperties =
94-
BigQueryJdbcUrlUtility.parseOverrideProperties(connectionString, null);
93+
Map<String, String> overrideProperties = new HashMap<>();
94+
overrideProperties.put(BigQueryJdbcUrlUtility.OAUTH2_TOKEN_URI_PROPERTY_NAME, "brokenuri{}");
9595

9696
try {
9797
BigQueryJdbcOAuthUtility.getCredentials(oauthProperties, overrideProperties, null);
@@ -234,8 +234,9 @@ public void testGenerateUserAuthURLOverrideOauthEndpoint() {
234234
+ ";";
235235
Map<String, String> authProperties =
236236
BigQueryJdbcOAuthUtility.parseOAuthProperties(connectionString, null);
237-
Map<String, String> overrideProperties =
238-
BigQueryJdbcUrlUtility.parseOverrideProperties(connectionString, null);
237+
Map<String, String> overrideProperties = new HashMap<>();
238+
overrideProperties.put(
239+
BigQueryJdbcUrlUtility.OAUTH2_TOKEN_URI_PROPERTY_NAME, overrideTokenSeverURI.toString());
239240

240241
UserAuthorizer userAuthorizer =
241242
BigQueryJdbcOAuthUtility.getUserAuthorizer(
@@ -274,8 +275,10 @@ public void testParseOverridePropsForRefreshTokenAuth() {
274275

275276
Map<String, String> authProperties =
276277
BigQueryJdbcOAuthUtility.parseOAuthProperties(connectionString, null);
277-
Map<String, String> overrideProperties =
278-
BigQueryJdbcUrlUtility.parseOverrideProperties(connectionString, null);
278+
Map<String, String> overrideProperties = new HashMap<>();
279+
overrideProperties.put(
280+
BigQueryJdbcUrlUtility.OAUTH2_TOKEN_URI_PROPERTY_NAME,
281+
"https://oauth2-private.p.googleapis.com/token");
279282

280283
UserCredentials userCredentials =
281284
BigQueryJdbcOAuthUtility.getPreGeneratedRefreshTokenCredentials(
@@ -296,9 +299,8 @@ public void testParseBYOIDProps() {
296299
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:433;OAuthType=4;"
297300
+ "ProjectId=MyBigQueryProject;"
298301
+ "BYOID_AudienceUri=//iam.googleapis.com/locations/global/workforcePools/pool-id/providers/provider-id;"
299-
+ "BYOID_PoolUserProject=workforceProjectNumber;"
300-
+ "BYOID_CredentialSource={\"file\": \"C:\\\\Token.txt\"};"
301-
+ "BYOID_SA_Impersonation_Uri=testSA;"
302+
+ "BYOID_PoolUserProject=workforceProjectNumber;BYOID_CredentialSource={\"file\":"
303+
+ " \"C:\\\\Token.txt\"};BYOID_SA_Impersonation_Uri=testSA;"
302304
+ "BYOID_SubjectTokenType=urn:ietf:params:oauth:tokentype:jwt;"
303305
+ "BYOID_TokenUri=https://testuri.com/v1/token",
304306
null);

0 commit comments

Comments
 (0)