aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2020-01-16 00:13:44 +0100
committerRoel Spilker <r.spilker@gmail.com>2020-01-20 13:55:43 +0100
commit18d70e7bc677cc1bd2e7c14f917543d88ac26ac9 (patch)
tree0edd0e384125070b7a4b4886888537596300fd18
parent7ca43108f52e0d4432f0266db5897eef919c71cf (diff)
downloadlombok-18d70e7bc677cc1bd2e7c14f917543d88ac26ac9.tar.gz
lombok-18d70e7bc677cc1bd2e7c14f917543d88ac26ac9.tar.bz2
lombok-18d70e7bc677cc1bd2e7c14f917543d88ac26ac9.zip
Close more inputstreams
-rwxr-xr-xsrc/delombok/lombok/delombok/Delombok.java14
-rw-r--r--src/launch/lombok/launch/ShadowClassLoader.java22
-rw-r--r--src/website/lombok/website/FetchCurrentVersion.java12
3 files changed, 30 insertions, 18 deletions
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index 7318a8ce..a1fd0e56 100755
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -354,11 +354,15 @@ public class Delombok {
StringBuilder s = new StringBuilder();
try {
InputStreamReader isr = new InputStreamReader(in, "UTF-8");
- char[] c = new char[4096];
- while (true) {
- int r = isr.read(c);
- if (r == -1) break;
- s.append(c, 0, r);
+ try {
+ char[] c = new char[4096];
+ while (true) {
+ int r = isr.read(c);
+ if (r == -1) break;
+ s.append(c, 0, r);
+ }
+ } finally {
+ isr.close();
}
} finally {
in.close();
diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java
index f2a21a4e..30ca6e97 100644
--- a/src/launch/lombok/launch/ShadowClassLoader.java
+++ b/src/launch/lombok/launch/ShadowClassLoader.java
@@ -364,16 +364,20 @@ class ShadowClassLoader extends ClassLoader {
FileInputStream jar = new FileInputStream(jarLoc);
try {
ZipInputStream zip = new ZipInputStream(jar);
- while (true) {
- ZipEntry entry = zip.getNextEntry();
- if (entry == null) {
- jarLocCache.put(key, false);
- return false;
+ try {
+ while (true) {
+ ZipEntry entry = zip.getNextEntry();
+ if (entry == null) {
+ jarLocCache.put(key, false);
+ return false;
+ }
+ if (!"META-INF/ShadowClassLoader".equals(entry.getName())) continue;
+ boolean v = sclFileContainsSuffix(zip, suffix);
+ jarLocCache.put(key, v);
+ return v;
}
- if (!"META-INF/ShadowClassLoader".equals(entry.getName())) continue;
- boolean v = sclFileContainsSuffix(zip, suffix);
- jarLocCache.put(key, v);
- return v;
+ } finally {
+ zip.close();
}
} finally {
jar.close();
diff --git a/src/website/lombok/website/FetchCurrentVersion.java b/src/website/lombok/website/FetchCurrentVersion.java
index 0d789256..d32c45dd 100644
--- a/src/website/lombok/website/FetchCurrentVersion.java
+++ b/src/website/lombok/website/FetchCurrentVersion.java
@@ -21,11 +21,15 @@ public class FetchCurrentVersion {
InputStream in = new URL("https://projectlombok.org/download").openStream();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
- for (String line = br.readLine(); line != null; line = br.readLine()) {
- Matcher m = VERSION_PATTERN.matcher(line);
- if (m.matches() && m.group(1).equals("currentVersionFull") == fetchFull) return m.group(2).replace("&quot;", "\"");
+ try {
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
+ Matcher m = VERSION_PATTERN.matcher(line);
+ if (m.matches() && m.group(1).equals("currentVersionFull") == fetchFull) return m.group(2).replace("&quot;", "\"");
+ }
+ throw new IOException("Expected a span with id 'currentVersion'");
+ } finally {
+ br.close();
}
- throw new IOException("Expected a span with id 'currentVersion'");
} finally {
in.close();
}