File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -73,10 +73,11 @@ public static String getAttribute(String attributeName) {
7373 connection .setConnectTimeout (TIMEOUT_MS );
7474 connection .setReadTimeout (TIMEOUT_MS );
7575 connection .setRequestProperty ("Metadata-Flavor" , "Google" );
76- InputStream input = connection .getInputStream ();
77- if (connection .getResponseCode () == 200 ) {
78- try (BufferedReader reader = new BufferedReader (new InputStreamReader (input , UTF_8 ))) {
79- return reader .readLine ();
76+ try (InputStream input = connection .getInputStream ()) {
77+ if (connection .getResponseCode () == 200 ) {
78+ try (BufferedReader reader = new BufferedReader (new InputStreamReader (input , UTF_8 ))) {
79+ return reader .readLine ();
80+ }
8081 }
8182 }
8283 } catch (IOException ignore ) {
You can’t perform that action at this time.
0 commit comments