Skip to content

Commit

Permalink
Use try-Closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
samie committed Feb 21, 2024
1 parent 04335d4 commit b6ec4a6
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,14 @@ protected ServiceAccountCredentials getCredentials() throws IOException {
return this.loadedCredentials;
}

InputStream in = new FileInputStream(credentialsFilePath);
if (in == null) {
throw new FileNotFoundException("Credentials not found: " + credentialsFilePath);
}
try (InputStream in = new FileInputStream(credentialsFilePath)) {
this.loadedCredentials = (ServiceAccountCredentials) ServiceAccountCredentials
.fromStream(new FileInputStream(credentialsFilePath))
.createScoped(AUTH_SCOPES);
this.loadedCredentials.refresh();
return this.loadedCredentials;
}

this.loadedCredentials = (ServiceAccountCredentials) ServiceAccountCredentials
.fromStream(new FileInputStream(credentialsFilePath))
.createScoped(AUTH_SCOPES);
this.loadedCredentials.refresh();
return this.loadedCredentials;
}

}

0 comments on commit b6ec4a6

Please sign in to comment.