Skip to content

Commit 0c030d0

Browse files
fix(jdbc): return null for invalid URLs in connect() to comply with JDBC spec (#4086)
1 parent f5a4852 commit 0c030d0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ public Connection connect(String url, Properties info) throws SQLException {
165165
this.toString()));
166166
return connection;
167167
} else {
168-
throw new IllegalArgumentException(
169-
"Invalid URL provided, must start with \"jdbc:bigquery:\"");
168+
return null;
170169
}
171170
} catch (IOException e) {
172171
LOG.warning("Getting a warning: " + e.getMessage());

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package com.google.cloud.bigquery.jdbc;
1717

1818
import static com.google.common.truth.Truth.assertThat;
19-
import static org.junit.Assert.assertThrows;
2019

2120
import java.sql.Connection;
2221
import java.sql.DriverPropertyInfo;
@@ -36,8 +35,8 @@ public void setUp() {
3635
}
3736

3837
@Test
39-
public void testInvalidURLDoesNotConnect() {
40-
assertThrows(IllegalArgumentException.class, () -> bigQueryDriver.connect("badURL.com", null));
38+
public void testInvalidURLReturnsNull() throws SQLException {
39+
assertThat(bigQueryDriver.connect("badURL.com", null)).isNull();
4140
}
4241

4342
@Test

0 commit comments

Comments
 (0)