aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment
diff options
context:
space:
mode:
authorGravatar laszlocsomor <laszlocsomor@google.com>2018-07-09 08:41:53 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-09 08:43:19 -0700
commitf0f5d101ddac1bce16b49fce828e85096c24bbfd (patch)
tree74a33191dd4dc6a00f6136d3a96e99ddf9ee7d46 /src/tools/android/java/com/google/devtools/build/android/incrementaldeployment
parent2f0033a6a314da8bf22eed6e08ef9d7cbb5d8ff1 (diff)
Bazel server, tools: ensure Readers are closed
Follow-up to commit 59f17d6e0550bf63a0b6ef182e2d63474e058ede. Use try-with-resources to ensure Reader objects are closed eagerly. Eagerly closing Readers avoids hanging on to file handles until the garbage collector finalizes the object, meaning Bazel on Windows (and other processes) can delete or mutate these files. Hopefully this avoids intermittent file deletion errors that sometimes occur on Windows. See https://github.com/bazelbuild/bazel/issues/5512 RELNOTES: none PiperOrigin-RevId: 203771262
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/incrementaldeployment')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/StubApplication.java5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/StubApplication.java b/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/StubApplication.java
index 0b91d03207..5cf15fad73 100644
--- a/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/StubApplication.java
+++ b/src/tools/android/java/com/google/devtools/build/android/incrementaldeployment/StubApplication.java
@@ -434,8 +434,7 @@ public class StubApplication extends Application {
private static Map<String, String> parseManifest(File file) throws IOException {
Map<String, String> result = new HashMap<>();
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
while (true) {
String line = reader.readLine();
if (line == null) {
@@ -445,8 +444,6 @@ public class StubApplication extends Application {
String[] items = line.split(" ");
result.put(items[0], items[1]);
}
- } finally {
- reader.close();
}
return result;