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,12 @@ 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
- }
73
-
70
+ // Download artifact
71
+ downloadFile (artifact , pluginSource , pluginTarget );
72
+ // Download artifact source
74
73
int index = artifact .lastIndexOf ("_" );
75
74
String source = artifact .substring (0 , index ) + ".source" + artifact .substring (index );
76
- try {
77
- downloadFile (source , pluginSource , pluginTarget );
78
- } catch (Exception e ) {
79
- }
75
+ downloadFile (source , pluginSource , pluginTarget );
80
76
}
81
77
82
78
writeEclipseLibrary (target , eclipseVersion );
@@ -102,23 +98,27 @@ private static void downloadFile(String filename, String repositoryUrl, String t
102
98
} catch (IOException e ) {
103
99
System .out .println ("[error]" );
104
100
} finally {
105
- if (in != null ) try {
106
- in .close ();
107
- } catch (Exception ignore ) {
108
- }
109
- if (out != null ) out .close ();
101
+ closeQuietly (in );
102
+ closeQuietly (out );
110
103
}
111
104
}
112
105
113
106
private static void copyZipButStripSignatures (InputStream rawIn , OutputStream rawOut ) throws IOException {
114
- ZipInputStream in = new ZipInputStream (rawIn );
115
- ZipOutputStream out = new ZipOutputStream (rawOut );
116
-
117
- ZipEntry zipEntry ;
118
- while ((zipEntry = in .getNextEntry ()) != null ) {
119
- if (zipEntry .getName ().matches ("META-INF/.*\\ .(SF|RSA)" )) continue ;
120
- out .putNextEntry (zipEntry );
121
- copy (in , out );
107
+ ZipInputStream in = null ;
108
+ 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 );
122
122
}
123
123
}
124
124
@@ -131,6 +131,15 @@ private static void copy(InputStream from, OutputStream to) throws IOException {
131
131
}
132
132
}
133
133
134
+ private static void closeQuietly (Closeable closeable ) {
135
+ if (closeable != null ) {
136
+ try {
137
+ closeable .close ();
138
+ } catch (IOException ignore ) {
139
+ }
140
+ }
141
+ }
142
+
134
143
private static InputStream getStreamForUrl (String url ) throws IOException , MalformedURLException {
135
144
HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
136
145
connection .setRequestProperty ("User-Agent" , "lombok" );
0 commit comments