aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks
diff options
context:
space:
mode:
authorKaloian Doganov <doganov@projectoria.bg>2012-03-02 22:02:43 +0200
committerKaloian Doganov <doganov@projectoria.bg>2012-03-08 12:25:27 +0200
commit763b15fd4fd4cf92b6aef2e29de98008894413a5 (patch)
tree0bb12690d7a71c23041f116d8d7ed24b47c69ff4 /anttasks
parentf0b625c2679ecd65345e4b33842d1773bf50cd8f (diff)
downloadsdk-763b15fd4fd4cf92b6aef2e29de98008894413a5.zip
sdk-763b15fd4fd4cf92b6aef2e29de98008894413a5.tar.gz
sdk-763b15fd4fd4cf92b6aef2e29de98008894413a5.tar.bz2
Close the dependency file after reading it.
The dependency file will be eventually closed by the finalize() method at some point, but it is not known when. In the meantime, the Ant recipe continues execution and may try to move or delete this file. At that point the build may fail because the file is still open. The solution is to explicitly close the BufferedReader opened by DependencyGraph.readFile(), so the underlying file is closed as soon as reading is finished. Change-Id: If25f0d430191f4265a73a0e6adc3d81764c63758 Signed-off-by: Kaloian Doganov <doganov@projectoria.bg>
Diffstat (limited to 'anttasks')
-rw-r--r--anttasks/src/com/android/ant/DependencyGraph.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/anttasks/src/com/android/ant/DependencyGraph.java b/anttasks/src/com/android/ant/DependencyGraph.java
index 8671359..ef059b9 100644
--- a/anttasks/src/com/android/ant/DependencyGraph.java
+++ b/anttasks/src/com/android/ant/DependencyGraph.java
@@ -436,13 +436,17 @@ public class DependencyGraph {
if (fStream != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(fStream));
- String line;
- StringBuilder total = new StringBuilder(reader.readLine());
- while ((line = reader.readLine()) != null) {
- total.append('\n');
- total.append(line);
+ try {
+ String line;
+ StringBuilder total = new StringBuilder(reader.readLine());
+ while ((line = reader.readLine()) != null) {
+ total.append('\n');
+ total.append(line);
+ }
+ return total.toString();
+ } finally {
+ reader.close();
}
- return total.toString();
}
} catch (IOException e) {
// we'll just return null