Skip to content

Commit ce4bdf5

Browse files
committed
nit
2 parents 1ae6b5f + 6148c0c commit ce4bdf5

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public Connection connect(String url, Properties info) throws SQLException {
127127
LOG.finest("++enter++");
128128
try {
129129
if (acceptsURL(url)) {
130-
// strip 'jdbc:' from the URL, add any extra properties
131130
String connectionUri =
132131
BigQueryJdbcUrlUtility.appendPropertiesToURL(url.substring(5), this.toString(), info);
133132
// LogLevel
@@ -151,12 +150,13 @@ public Connection connect(String url, Properties info) throws SQLException {
151150
}
152151

153152
BigQueryJdbcRootLogger.setLevel(logLevel, logPath);
153+
154154
// Logging starts from here.
155155
DataSource ds;
156156
try {
157157
ds = DataSource.fromUrl(connectionUri);
158158
} catch (BigQueryJdbcRuntimeException e) {
159-
LOG.severe("Failed to parse connection URL", e);
159+
LOG.log(Level.SEVERE, "Failed to parse connection URL", e);
160160
throw new BigQueryJdbcException("Failed to parse connection URL", e);
161161
}
162162

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,21 @@ public void testUnknownPropertyWarningIsLogged() throws SQLException {
129129

130130
@Test
131131
public void testMalformedUrlExceptionIsLogged() {
132-
try {
133-
bigQueryDriver.connect(
134-
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
135-
+ "OAuthType=2;OAuthAccessToken=redactedToken;ProjectId=t;LogLevel=3;"
136-
+ "MalformedPropertyWithoutEquals",
137-
new Properties());
138-
Assertions.fail("Should have thrown BigQueryJdbcException");
139-
} catch (SQLException e) {
140-
boolean foundSevere =
141-
capturedLogs.stream()
142-
.anyMatch(
143-
r ->
144-
r.getLevel() == Level.SEVERE
145-
&& r.getMessage().contains("Failed to parse connection URL"));
146-
assertThat(foundSevere).isTrue();
147-
}
132+
Assertions.assertThrows(
133+
SQLException.class,
134+
() ->
135+
bigQueryDriver.connect(
136+
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
137+
+ "OAuthType=2;OAuthAccessToken=redactedToken;ProjectId=t;LogLevel=3;"
138+
+ "MalformedPropertyWithoutEquals",
139+
new Properties()));
140+
141+
boolean foundSevere =
142+
capturedLogs.stream()
143+
.anyMatch(
144+
r ->
145+
r.getLevel() == Level.SEVERE
146+
&& r.getMessage().contains("Failed to parse connection URL"));
147+
assertThat(foundSevere).isTrue();
148148
}
149149
}

0 commit comments

Comments
 (0)