Skip to content

Commit 03cd61a

Browse files
committed
Merge branch 'eclipse-tests-fix'
2 parents 87bc91a + 7a9f3a8 commit 03cd61a

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java

+16-18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.io.BufferedInputStream;
2525
import java.io.ByteArrayInputStream;
26+
import java.io.Closeable;
2627
import java.io.File;
2728
import java.io.FileOutputStream;
2829
import java.io.FilenameFilter;
@@ -66,17 +67,13 @@ public static void main(String[] args) throws Exception {
6667
String pluginSource = updateSite.getResolvedUrl() + "/plugins/";
6768

6869
for (String artifact : artifacts) {
69-
try {
70-
downloadFile(artifact, pluginSource, pluginTarget);
71-
} catch (Exception e) {
72-
}
70+
// Download artifact
71+
downloadFile(artifact, pluginSource, pluginTarget);
7372

73+
// Download artifact source
7474
int index = artifact.lastIndexOf("_");
7575
String source = artifact.substring(0, index) + ".source" + artifact.substring(index);
76-
try {
77-
downloadFile(source, pluginSource, pluginTarget);
78-
} catch (Exception e) {
79-
}
76+
downloadFile(source, pluginSource, pluginTarget);
8077
}
8178

8279
writeEclipseLibrary(target, eclipseVersion);
@@ -99,27 +96,29 @@ private static void downloadFile(String filename, String repositoryUrl, String t
9996

10097
copyZipButStripSignatures(in, out);
10198
System.out.println("[done]");
102-
} catch (IOException e) {
103-
System.out.println("[error]");
10499
} finally {
105-
if (in != null) try {
106-
in.close();
107-
} catch (Exception ignore) {
100+
try {
101+
if (in != null) in.close();
102+
} finally {
103+
if (out != null) out.close();
108104
}
109-
if (out != null) out.close();
110105
}
111106
}
112107

113108
private static void copyZipButStripSignatures(InputStream rawIn, OutputStream rawOut) throws IOException {
114-
ZipInputStream in = new ZipInputStream(rawIn);
115-
ZipOutputStream out = new ZipOutputStream(rawOut);
109+
ZipInputStream in = null;
110+
ZipOutputStream out = null;
111+
112+
in = new ZipInputStream(rawIn);
113+
out = new ZipOutputStream(rawOut);
116114

117115
ZipEntry zipEntry;
118116
while ((zipEntry = in.getNextEntry()) != null) {
119117
if (zipEntry.getName().matches("META-INF/.*\\.(SF|RSA)")) continue;
120118
out.putNextEntry(zipEntry);
121119
copy(in, out);
122120
}
121+
out.close(); // zip streams buffer.
123122
}
124123

125124
private static void copy(InputStream from, OutputStream to) throws IOException {
@@ -135,8 +134,7 @@ private static InputStream getStreamForUrl(String url) throws IOException, Malfo
135134
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
136135
connection.setRequestProperty("User-Agent", "lombok");
137136
connection.setRequestProperty("Accept", "*/*");
138-
InputStream in = new BufferedInputStream(connection.getInputStream());
139-
return in;
137+
return new BufferedInputStream(connection.getInputStream());
140138
}
141139

142140
private static void writeEclipseLibrary(String target, String eclipseVersion) throws IOException {

0 commit comments

Comments
 (0)