69
69
import java .util .concurrent .atomic .AtomicBoolean ;
70
70
import java .util .concurrent .atomic .AtomicLong ;
71
71
import java .util .function .Function ;
72
- import java .util .jar .JarFile ;
72
+ import java .util .jar .JarInputStream ;
73
73
import java .util .regex .Pattern ;
74
74
import java .util .stream .Collectors ;
75
75
import java .util .stream .Stream ;
76
- import java .util .zip .ZipFile ;
76
+ import java .util .zip .ZipEntry ;
77
77
78
78
public class DependencyLoaderImpl {
79
79
@@ -191,14 +191,13 @@ private static Stream<URL> scanSourceMetaInf(URL source) {
191
191
return Stream .empty ();
192
192
}
193
193
LOG .debug ("Scanning {} for dependencies" , source );
194
- val path = source .getPath ();
194
+ val fileName = source .getFile ();
195
195
val output = new ArrayList <URL >();
196
- if (path .endsWith (".jar" ) || path . endsWith ( ".zip " )) {
196
+ if (fileName .endsWith (".jar" )) {
197
197
//Scan jar file for json in META-INF, add them to the list
198
- try (val jarFile = (ZipFile )(path .endsWith ("jar" ) ? new JarFile (path ) : new ZipFile (path ))) {
199
- val entries = jarFile .entries ();
200
- while (entries .hasMoreElements ()) {
201
- val entry = entries .nextElement ();
198
+ try (val inputStream = source .openStream (); val jarFile = new JarInputStream (inputStream )) {
199
+ ZipEntry entry ;
200
+ while ((entry = jarFile .getNextEntry ()) != null ) {
202
201
if (!entry .getName ().startsWith ("META-INF" ) || !entry .getName ().endsWith (".json" )) {
203
202
continue ;
204
203
}
@@ -209,12 +208,12 @@ private static Stream<URL> scanSourceMetaInf(URL source) {
209
208
}
210
209
}
211
210
} catch (IOException e ) {
212
- LOG .error ("Failed to open jar file {}" , path );
211
+ LOG .error ("Failed to open jar file {}" , source . getPath () );
213
212
}
214
213
} else {
215
- val dir = new File (path );
214
+ val dir = new File (fileName );
216
215
if (!dir .exists () || !dir .isDirectory ()) {
217
- LOG .warn ("Skipping non-directory, nor jar, nor zip source: {}" , source );
216
+ LOG .warn ("Skipping non-directory, nor jar source: {}" , source );
218
217
return Stream .empty ();
219
218
}
220
219
//Scan directory for json in META-INF, add them to the list
0 commit comments