This is an automated email from the ASF dual-hosted git repository. pascalschumacher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit d0d2df571400e87f130866c3eced085504b7e125 Author: Pascal Schumacher <pascalschumac...@gmx.net> AuthorDate: Sun Dec 29 16:36:11 2019 +0100 camel-google-bigquery: Close the FileInputStream in GoogleBigQueryConnectionFactory#createFromFile --- .../google/bigquery/GoogleBigQueryConnectionFactory.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java index 3c7db1d..5fc3536 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java @@ -113,14 +113,15 @@ public class GoogleBigQueryConnectionFactory { } private GoogleCredential createFromFile() throws Exception { + try (InputStream is = new FileInputStream(credentialsFileLocation)) { + GoogleCredential credential = GoogleCredential.fromStream(is); - GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(credentialsFileLocation)); + if (credential.createScopedRequired()) { + credential = credential.createScoped(BigqueryScopes.all()); + } - if (credential.createScopedRequired()) { - credential = credential.createScoped(BigqueryScopes.all()); + return credential; } - - return credential; } private GoogleCredential createDefault() throws Exception {