@@ -147,10 +147,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
147147 DataSource ds = DataSource .fromUrl (url );
148148
149149 this .labels = ds .getLabels () != null ? ds .getLabels () : new java .util .HashMap <>();
150- this .maxBytesBilled =
151- ds .getMaximumBytesBilled () != null
152- ? ds .getMaximumBytesBilled ()
153- : BigQueryJdbcUrlUtility .DEFAULT_MAX_BYTES_BILLED_VALUE ;
150+ this .maxBytesBilled = ds .getMaximumBytesBilled ();
154151 this .retryTimeoutInSeconds = ds .getTimeout ();
155152 this .retryTimeoutDuration = Duration .ofMillis (retryTimeoutInSeconds * 1000L );
156153 this .retryInitialDelayInSeconds = ds .getRetryInitialDelay ();
@@ -160,24 +157,12 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
160157 this .jobTimeoutInSeconds = ds .getJobTimeout ();
161158 this .authProperties =
162159 BigQueryJdbcOAuthUtility .parseOAuthProperties (ds , this .connectionClassName );
163- this .catalog =
164- ds .getProjectId () != null ? ds .getProjectId () : BigQueryOptions .getDefaultProjectId ();
160+ this .catalog = ds .getProjectId ();
165161 this .universeDomain = ds .getUniverseDomain ();
166162
167- this .overrideProperties = new java .util .HashMap <>();
168- if (ds .getOAuth2TokenUri () != null ) {
169- this .overrideProperties .put (
170- BigQueryJdbcUrlUtility .OAUTH2_TOKEN_URI_PROPERTY_NAME , ds .getOAuth2TokenUri ());
171- }
172- if (ds .getEndpointOverrides () != null ) {
173- this .overrideProperties .put (
174- BigQueryJdbcUrlUtility .ENDPOINT_OVERRIDES_PROPERTY_NAME , ds .getEndpointOverrides ());
175- }
176- if (ds .getPrivateServiceConnect () != null ) {
177- this .overrideProperties .put (
178- BigQueryJdbcUrlUtility .PRIVATE_SERVICE_CONNECT_PROPERTY_NAME ,
179- ds .getPrivateServiceConnect ());
180- }
163+ this .overrideProperties =
164+ BigQueryJdbcUrlUtility .parseOverrideProperties (
165+ this .connectionUrl , this .connectionClassName );
181166 if (this .universeDomain != null ) {
182167 this .overrideProperties .put (
183168 BigQueryJdbcUrlUtility .UNIVERSE_DOMAIN_OVERRIDE_PROPERTY_NAME , this .universeDomain );
@@ -206,7 +191,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
206191 this .highThroughputActivationRatio = ds .getHighThroughputActivationRatio ();
207192 this .useQueryCache = ds .getUseQueryCache ();
208193 Integer jobCreationMode = ds .getJobCreationMode ();
209- if (jobCreationMode == null || jobCreationMode == 2 ) {
194+ if (jobCreationMode == 2 ) {
210195 this .useStatelessQueryMode = true ;
211196 } else if (jobCreationMode == 1 ) {
212197 this .useStatelessQueryMode = false ;
@@ -224,47 +209,8 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
224209 this .destinationDataset = ds .getDestinationDataset ();
225210 this .destinationDatasetExpirationTime = ds .getDestinationDatasetExpirationTime ();
226211 this .kmsKeyName = ds .getKmsKeyName ();
227- Map <String , String > proxyProperties = new java .util .HashMap <>();
228- if (ds .getProxyHost () != null )
229- proxyProperties .put (BigQueryJdbcUrlUtility .PROXY_HOST_PROPERTY_NAME , ds .getProxyHost ());
230- if (ds .getProxyPort () != null )
231- proxyProperties .put (BigQueryJdbcUrlUtility .PROXY_PORT_PROPERTY_NAME , ds .getProxyPort ());
232- if (ds .getProxyUid () != null )
233- proxyProperties .put (BigQueryJdbcUrlUtility .PROXY_USER_ID_PROPERTY_NAME , ds .getProxyUid ());
234- if (ds .getProxyPwd () != null )
235- proxyProperties .put (BigQueryJdbcUrlUtility .PROXY_PASSWORD_PROPERTY_NAME , ds .getProxyPwd ());
236- String proxyHost = ds .getProxyHost ();
237- String proxyPort = ds .getProxyPort ();
238- String proxyUid = ds .getProxyUid ();
239- String proxyPwd = ds .getProxyPwd ();
240-
241- if (proxyPort != null
242- && !java .util .regex .Pattern .compile (
243- "^([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" )
244- .matcher (proxyPort )
245- .find ()) {
246- throw new IllegalArgumentException (
247- "Illegal port number provided %s. Please provide a valid port number." );
248- }
249-
250- boolean isMissingProxyHostOrPortWhenProxySet =
251- (proxyHost == null && proxyPort != null ) || (proxyHost != null && proxyPort == null );
252- if (isMissingProxyHostOrPortWhenProxySet ) {
253- throw new IllegalArgumentException (
254- "Both ProxyHost and ProxyPort parameters need to be specified. No defaulting behavior"
255- + " occurs." );
256- }
257- boolean isMissingProxyUidOrPwdWhenAuthSet =
258- (proxyUid == null && proxyPwd != null ) || (proxyUid != null && proxyPwd == null );
259- if (isMissingProxyUidOrPwdWhenAuthSet ) {
260- throw new IllegalArgumentException (
261- "Both ProxyUid and ProxyPwd parameters need to be specified for authentication." );
262- }
263- boolean isProxyAuthSetWithoutProxySettings = proxyUid != null && proxyHost == null ;
264- if (isProxyAuthSetWithoutProxySettings ) {
265- throw new IllegalArgumentException (
266- "Proxy authentication provided via connection string with no proxy host or port set." );
267- }
212+ Map <String , String > proxyProperties =
213+ BigQueryJdbcProxyUtility .parseProxyProperties (ds , this .connectionClassName );
268214
269215 this .sslTrustStorePath = ds .getSSLTrustStorePath ();
270216 this .sslTrustStorePassword = ds .getSSLTrustStorePassword ();
@@ -291,37 +237,19 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
291237 Map <String , String > queryPropertiesMap = ds .getQueryProperties ();
292238 this .sessionInfoConnectionProperty = getSessionPropertyFromQueryProperties (queryPropertiesMap );
293239 this .queryProperties = convertMapToConnectionPropertiesList (queryPropertiesMap );
294- this .enableWriteAPI =
295- ds .getEnableWriteAPI () != null
296- ? ds .getEnableWriteAPI ()
297- : BigQueryJdbcUrlUtility .DEFAULT_ENABLE_WRITE_API_VALUE ;
298- this .writeAPIActivationRowCount =
299- ds .getSwaActivationRowCount () != null
300- ? ds .getSwaActivationRowCount ()
301- : BigQueryJdbcUrlUtility .DEFAULT_SWA_ACTIVATION_ROW_COUNT_VALUE ;
302- this .writeAPIAppendRowCount =
303- ds .getSwaAppendRowCount () != null
304- ? ds .getSwaAppendRowCount ()
305- : BigQueryJdbcUrlUtility .DEFAULT_SWA_APPEND_ROW_COUNT_VALUE ;
240+ this .enableWriteAPI = ds .getEnableWriteAPI ();
241+ this .writeAPIActivationRowCount = ds .getSwaActivationRowCount ();
242+ this .writeAPIAppendRowCount = ds .getSwaAppendRowCount ();
306243
307244 String additionalProjectsStr = ds .getAdditionalProjects ();
308245 this .additionalProjects =
309246 (additionalProjectsStr == null || additionalProjectsStr .isEmpty ())
310247 ? java .util .Collections .emptyList ()
311248 : java .util .Arrays .asList (additionalProjectsStr .split ("," ));
312249
313- this .filterTablesOnDefaultDataset =
314- ds .getFilterTablesOnDefaultDataset () != null
315- ? ds .getFilterTablesOnDefaultDataset ()
316- : BigQueryJdbcUrlUtility .DEFAULT_FILTER_TABLES_ON_DEFAULT_DATASET_VALUE ;
317- this .requestGoogleDriveScope =
318- ds .getRequestGoogleDriveScope () != null
319- ? ds .getRequestGoogleDriveScope ()
320- : BigQueryJdbcUrlUtility .DEFAULT_REQUEST_GOOGLE_DRIVE_SCOPE_VALUE ;
321- this .metadataFetchThreadCount =
322- ds .getMetadataFetchThreadCount () != null
323- ? ds .getMetadataFetchThreadCount ()
324- : BigQueryJdbcUrlUtility .DEFAULT_METADATA_FETCH_THREAD_COUNT_VALUE ;
250+ this .filterTablesOnDefaultDataset = ds .getFilterTablesOnDefaultDataset ();
251+ this .requestGoogleDriveScope = ds .getRequestGoogleDriveScope ();
252+ this .metadataFetchThreadCount = ds .getMetadataFetchThreadCount ();
325253 this .requestReason = ds .getRequestReason ();
326254 this .connectionPoolSize = ds .getConnectionPoolSize ();
327255 this .listenerPoolSize = ds .getListenerPoolSize ();
0 commit comments