File tree Expand file tree Collapse file tree
java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -544,22 +544,29 @@ public static <T> T withTracing(
544544 }
545545
546546 private static ProxyOptions createProxyOptions (Map <String , String > proxyProperties ) {
547- if (proxyProperties == null
548- || !proxyProperties .containsKey (BigQueryJdbcUrlUtility .PROXY_HOST_PROPERTY_NAME )
549- || !proxyProperties .containsKey (BigQueryJdbcUrlUtility .PROXY_PORT_PROPERTY_NAME )) {
547+ if (proxyProperties == null ) {
550548 return null ;
551549 }
552550
553551 final String host = proxyProperties .get (BigQueryJdbcUrlUtility .PROXY_HOST_PROPERTY_NAME );
554- final int port =
555- Integer .parseInt (proxyProperties .get (BigQueryJdbcUrlUtility .PROXY_PORT_PROPERTY_NAME ));
552+ final String portStr = proxyProperties .get (BigQueryJdbcUrlUtility .PROXY_PORT_PROPERTY_NAME );
553+ if (host == null || host .isEmpty () || portStr == null || portStr .isEmpty ()) {
554+ return null ;
555+ }
556+
557+ int port ;
558+ try {
559+ port = Integer .parseInt (portStr );
560+ } catch (NumberFormatException e ) {
561+ throw new BigQueryJdbcRuntimeException ("Invalid proxy port number: " + portStr , e );
562+ }
556563
557564 ProxySelector proxySelector =
558565 new ProxySelector () {
559566 @ Override
560567 public List <Proxy > select (URI uri ) {
561568 return Collections .singletonList (
562- new Proxy (Proxy .Type .HTTP , new InetSocketAddress (host , port )));
569+ new Proxy (Proxy .Type .HTTP , InetSocketAddress . createUnresolved (host , port )));
563570 }
564571
565572 @ Override
You can’t perform that action at this time.
0 commit comments