Skip to content

Commit 9a2198c

Browse files
committed
fix the rest of the logs
1 parent fe63988 commit 9a2198c

7 files changed

Lines changed: 51 additions & 29 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/exception/BigQueryJdbcRuntimeException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.bigquery.exception;
1818

19+
1920
public class BigQueryJdbcRuntimeException extends RuntimeException {
2021

2122
/**
@@ -45,4 +46,8 @@ public BigQueryJdbcRuntimeException(Throwable ex) {
4546
public BigQueryJdbcRuntimeException(String message, InterruptedException ex) {
4647
super(message, ex);
4748
}
49+
50+
public BigQueryJdbcRuntimeException(String message, Throwable ex) {
51+
super(message, ex);
52+
}
4853
}

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ private BigQueryArrowResultSet(
108108
try {
109109
this.arrowDeserializer = new ArrowDeserializer(arrowSchema);
110110
} catch (IOException ex) {
111-
LOG.severe(ex, "IOException during ArrowDeserializer creation");
112-
throw new BigQueryJdbcException(ex);
111+
BigQueryJdbcException e =
112+
new BigQueryJdbcException("IOException during ArrowDeserializer creation", ex);
113+
LOG.severe(e, e.getMessage());
114+
throw e;
113115
}
114116
}
115117
}
@@ -274,12 +276,12 @@ else if (this.currentBatchRowIndex < this.vectorSchemaRoot.getRowCount()) {
274276
return true;
275277
}
276278
} catch (InterruptedException | SQLException ex) {
277-
LOG.severe(
278-
ex,
279-
"Error occurred while advancing the cursor. This could happen when connection is closed while the next method is being called.");
280-
throw new BigQueryJdbcException(
281-
"Error occurred while advancing the cursor. This could happen when connection is closed while the next method is being called.",
282-
ex);
279+
BigQueryJdbcException e =
280+
new BigQueryJdbcException(
281+
"Error occurred while advancing the cursor. This could happen when connection is closed while the next method is being called.",
282+
ex);
283+
LOG.severe(e, e.getMessage());
284+
throw e;
283285
}
284286
}
285287
return false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ String getLibraryVersion(Class<?> libraryClass) {
270270
version = props.getProperty("version.jdbc");
271271
}
272272
} catch (IOException e) {
273-
LOG.severe(e, "Failed to load dependencies.properties");
273+
LOG.warning("Failed to load dependencies.properties");
274274
return DEFAULT_VERSION;
275275
}
276276

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ private static GoogleCredentials getGoogleServiceAccountCredentials(
387387
overrideProperties.get(BigQueryJdbcUrlUtility.UNIVERSE_DOMAIN_OVERRIDE_PROPERTY_NAME));
388388
}
389389
} catch (URISyntaxException | IOException e) {
390-
LOG.severe(e, "Validation failure for Service Account credentials.");
391-
throw new BigQueryJdbcRuntimeException(e);
390+
BigQueryJdbcRuntimeException ex =
391+
new BigQueryJdbcRuntimeException(
392+
"Validation failure for Service Account credentials.", e);
393+
LOG.severe(ex, ex.getMessage());
394+
throw ex;
392395
}
393396
LOG.info("GoogleCredentials instantiated. Auth Method: Service Account.");
394397
return builder.build();
@@ -523,8 +526,11 @@ static GoogleCredentials getPreGeneratedTokensCredentials(
523526
return getPreGeneratedRefreshTokenCredentials(
524527
authProperties, overrideProperties, callerClassName);
525528
} catch (URISyntaxException ex) {
526-
LOG.severe(ex, "URISyntaxException during getPreGeneratedTokensCredentials");
527-
throw new BigQueryJdbcRuntimeException(ex);
529+
BigQueryJdbcRuntimeException e =
530+
new BigQueryJdbcRuntimeException(
531+
"URISyntaxException during getPreGeneratedTokensCredentials", ex);
532+
LOG.severe(e, e.getMessage());
533+
throw e;
528534
}
529535
} else {
530536
return getPreGeneratedAccessTokenCredentials(
@@ -579,8 +585,10 @@ private static GoogleCredentials getApplicationDefaultCredentials(String callerC
579585

580586
return credentials;
581587
} catch (IOException exception) {
582-
LOG.severe(exception, "Application default credentials not found.");
583-
throw new BigQueryJdbcRuntimeException("Application default credentials not found.");
588+
BigQueryJdbcRuntimeException e =
589+
new BigQueryJdbcRuntimeException("Application default credentials not found.", exception);
590+
LOG.severe(e, e.getMessage());
591+
throw e;
584592
}
585593
}
586594

@@ -635,8 +643,11 @@ private static GoogleCredentials getExternalAccountAuthCredentials(
635643
throw ex;
636644
}
637645
} catch (IOException e) {
638-
LOG.severe(e, "IOException during getExternalAccountAuthCredentials");
639-
throw new BigQueryJdbcRuntimeException(e);
646+
BigQueryJdbcRuntimeException ex =
647+
new BigQueryJdbcRuntimeException(
648+
"IOException during getExternalAccountAuthCredentials", e);
649+
LOG.severe(ex, ex.getMessage());
650+
throw ex;
640651
}
641652
}
642653

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,14 @@ public boolean next() throws SQLException {
178178
// Cursor has been advanced
179179
return true;
180180

181-
} catch (InterruptedException ex) {
182-
LOG.severe(
183-
ex,
184-
"Error occurred while advancing the cursor. This could happen when connection is closed while we call the next method");
185-
throw new BigQueryJdbcRuntimeException(
186-
"Error occurred while advancing the cursor. This could happen when connection is closed while we call the next method",
187-
ex);
181+
} catch (InterruptedException e) {
182+
183+
BigQueryJdbcRuntimeException ex =
184+
new BigQueryJdbcRuntimeException(
185+
"Error occurred while advancing the cursor. This could happen when connection is closed while we call the next method",
186+
e);
187+
LOG.severe(ex, ex.getMessage());
188+
throw ex;
188189
}
189190
}
190191
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ <T> T coerceTo(Class<T> targetClass, Object value) {
121121
try {
122122
return coercion.coerce(sourceClass != Void.class ? value : null);
123123
} catch (Exception ex) {
124-
LOG.severe(ex, "Coercion failed");
125-
throw new BigQueryJdbcCoercionException(ex);
124+
BigQueryJdbcCoercionException e = new BigQueryJdbcCoercionException(ex);
125+
LOG.severe(e, "Coercion failed");
126+
throw e;
126127
}
127128
}
128129

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ public Time coerce(FieldValue fieldValue) {
258258
long millis = TimeUnit.NANOSECONDS.toMillis(localTime.toNanoOfDay());
259259
return new Time(millis);
260260
} catch (java.time.format.DateTimeParseException e) {
261-
LOG.severe(e, "Cannot parse the value to java.sql.Time");
262-
throw new IllegalArgumentException(
263-
"Cannot parse the value " + strTime + " to java.sql.Time", e);
261+
IllegalArgumentException ex =
262+
new IllegalArgumentException(
263+
"Cannot parse the value " + strTime + " to java.sql.Time", e);
264+
LOG.severe(ex, ex.getMessage());
265+
throw ex;
264266
}
265267
}
266268
}

0 commit comments

Comments
 (0)