Skip to content

Commit 9fa93ac

Browse files
SC-1431 - try-with-resources pattern.
1 parent ed3e395 commit 9fa93ac

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

api/src/main/java/org/sonarsource/scanner/api/internal/ServerConnection.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ public void downloadFile(String urlPath, Path toFile) throws IOException {
7575
}
7676
String url = baseUrlWithoutTrailingSlash + urlPath;
7777
logger.debug(format("Download %s to %s", url, toFile.toAbsolutePath().toString()));
78-
ResponseBody responseBody = callUrl(url);
7978

80-
try (InputStream in = responseBody.byteStream()) {
79+
try (ResponseBody responseBody = callUrl(url);
80+
InputStream in = responseBody.byteStream()) {
8181
Files.copy(in, toFile, StandardCopyOption.REPLACE_EXISTING);
8282
} catch (IOException | RuntimeException e) {
8383
Utils.deleteQuietly(toFile);
8484
throw e;
85-
}finally {
86-
responseBody.close();
8785
}
8886
}
8987

0 commit comments

Comments
 (0)