aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉamonn McManus <emcmanus@google.com>2023-05-17 13:20:24 -0700
committerJavac Team <javac-team+copybara@google.com>2023-05-17 13:21:05 -0700
commit58d552ad1161670c4b419a07814a3c06763d4327 (patch)
treece4d1b8d37120d784d6a3ee596a9c61ff6d1d3ca
parent0f203454983d11f842f1b3193799a0f4553228a2 (diff)
downloadturbine-58d552ad1161670c4b419a07814a3c06763d4327.tar.gz
Ensure that source jars are closed after being read.
PiperOrigin-RevId: 532885339
-rw-r--r--java/com/google/turbine/main/Main.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/com/google/turbine/main/Main.java b/java/com/google/turbine/main/Main.java
index 34984a8..45b0538 100644
--- a/java/com/google/turbine/main/Main.java
+++ b/java/com/google/turbine/main/Main.java
@@ -320,11 +320,13 @@ public final class Main {
units.add(Parser.parse(new SourceFile(source, MoreFiles.asCharSource(path, UTF_8).read())));
}
for (String sourceJar : options.sourceJars()) {
- for (Zip.Entry ze : new Zip.ZipIterable(Paths.get(sourceJar))) {
- if (ze.name().endsWith(".java")) {
- String name = ze.name();
- String source = new String(ze.data(), UTF_8);
- units.add(Parser.parse(new SourceFile(name, source)));
+ try (Zip.ZipIterable iterable = new Zip.ZipIterable(Paths.get(sourceJar))) {
+ for (Zip.Entry ze : iterable) {
+ if (ze.name().endsWith(".java")) {
+ String name = ze.name();
+ String source = new String(ze.data(), UTF_8);
+ units.add(Parser.parse(new SourceFile(name, source)));
+ }
}
}
}