@@ -69,6 +69,7 @@ public static void main(String[] args) throws Exception {
69
69
for (String artifact : artifacts ) {
70
70
// Download artifact
71
71
downloadFile (artifact , pluginSource , pluginTarget );
72
+
72
73
// Download artifact source
73
74
int index = artifact .lastIndexOf ("_" );
74
75
String source = artifact .substring (0 , index ) + ".source" + artifact .substring (index );
@@ -95,31 +96,29 @@ private static void downloadFile(String filename, String repositoryUrl, String t
95
96
96
97
copyZipButStripSignatures (in , out );
97
98
System .out .println ("[done]" );
98
- } catch (IOException e ) {
99
- System .out .println ("[error]" );
100
99
} finally {
101
- closeQuietly (in );
102
- closeQuietly (out );
100
+ try {
101
+ if (in != null ) in .close ();
102
+ } finally {
103
+ if (out != null ) out .close ();
104
+ }
103
105
}
104
106
}
105
107
106
108
private static void copyZipButStripSignatures (InputStream rawIn , OutputStream rawOut ) throws IOException {
107
109
ZipInputStream in = null ;
108
110
ZipOutputStream out = null ;
109
- try {
110
- in = new ZipInputStream (rawIn );
111
- out = new ZipOutputStream (rawOut );
112
-
113
- ZipEntry zipEntry ;
114
- while ((zipEntry = in .getNextEntry ()) != null ) {
115
- if (zipEntry .getName ().matches ("META-INF/.*\\ .(SF|RSA)" )) continue ;
116
- out .putNextEntry (zipEntry );
117
- copy (in , out );
118
- }
119
- } finally {
120
- closeQuietly (in );
121
- closeQuietly (out );
111
+
112
+ in = new ZipInputStream (rawIn );
113
+ out = new ZipOutputStream (rawOut );
114
+
115
+ ZipEntry zipEntry ;
116
+ while ((zipEntry = in .getNextEntry ()) != null ) {
117
+ if (zipEntry .getName ().matches ("META-INF/.*\\ .(SF|RSA)" )) continue ;
118
+ out .putNextEntry (zipEntry );
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 {
@@ -131,21 +130,11 @@ private static void copy(InputStream from, OutputStream to) throws IOException {
131
130
}
132
131
}
133
132
134
- private static void closeQuietly (Closeable closeable ) {
135
- if (closeable != null ) {
136
- try {
137
- closeable .close ();
138
- } catch (IOException ignore ) {
139
- }
140
- }
141
- }
142
-
143
133
private static InputStream getStreamForUrl (String url ) throws IOException , MalformedURLException {
144
134
HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
145
135
connection .setRequestProperty ("User-Agent" , "lombok" );
146
136
connection .setRequestProperty ("Accept" , "*/*" );
147
- InputStream in = new BufferedInputStream (connection .getInputStream ());
148
- return in ;
137
+ return new BufferedInputStream (connection .getInputStream ());
149
138
}
150
139
151
140
private static void writeEclipseLibrary (String target , String eclipseVersion ) throws IOException {
0 commit comments