23
23
24
24
import java .io .BufferedInputStream ;
25
25
import java .io .ByteArrayInputStream ;
26
+ import java .io .Closeable ;
26
27
import java .io .File ;
27
28
import java .io .FileOutputStream ;
28
29
import java .io .FilenameFilter ;
@@ -66,17 +67,13 @@ public static void main(String[] args) throws Exception {
66
67
String pluginSource = updateSite .getResolvedUrl () + "/plugins/" ;
67
68
68
69
for (String artifact : artifacts ) {
69
- try {
70
- downloadFile (artifact , pluginSource , pluginTarget );
71
- } catch (Exception e ) {
72
- }
70
+ // Download artifact
71
+ downloadFile (artifact , pluginSource , pluginTarget );
73
72
73
+ // Download artifact source
74
74
int index = artifact .lastIndexOf ("_" );
75
75
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 );
80
77
}
81
78
82
79
writeEclipseLibrary (target , eclipseVersion );
@@ -99,27 +96,29 @@ private static void downloadFile(String filename, String repositoryUrl, String t
99
96
100
97
copyZipButStripSignatures (in , out );
101
98
System .out .println ("[done]" );
102
- } catch (IOException e ) {
103
- System .out .println ("[error]" );
104
99
} 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 ();
108
104
}
109
- if (out != null ) out .close ();
110
105
}
111
106
}
112
107
113
108
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 );
116
114
117
115
ZipEntry zipEntry ;
118
116
while ((zipEntry = in .getNextEntry ()) != null ) {
119
117
if (zipEntry .getName ().matches ("META-INF/.*\\ .(SF|RSA)" )) continue ;
120
118
out .putNextEntry (zipEntry );
121
119
copy (in , out );
122
120
}
121
+ out .close (); // zip streams buffer.
123
122
}
124
123
125
124
private static void copy (InputStream from , OutputStream to ) throws IOException {
@@ -135,8 +134,7 @@ private static InputStream getStreamForUrl(String url) throws IOException, Malfo
135
134
HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
136
135
connection .setRequestProperty ("User-Agent" , "lombok" );
137
136
connection .setRequestProperty ("Accept" , "*/*" );
138
- InputStream in = new BufferedInputStream (connection .getInputStream ());
139
- return in ;
137
+ return new BufferedInputStream (connection .getInputStream ());
140
138
}
141
139
142
140
private static void writeEclipseLibrary (String target , String eclipseVersion ) throws IOException {
0 commit comments