6969import java .util .concurrent .atomic .AtomicBoolean ;
7070import java .util .concurrent .atomic .AtomicLong ;
7171import java .util .function .Function ;
72- import java .util .jar .JarFile ;
72+ import java .util .jar .JarInputStream ;
7373import java .util .regex .Pattern ;
7474import java .util .stream .Collectors ;
7575import java .util .stream .Stream ;
76- import java .util .zip .ZipFile ;
76+ import java .util .zip .ZipEntry ;
7777
7878public class DependencyLoaderImpl {
7979
@@ -191,14 +191,13 @@ private static Stream<URL> scanSourceMetaInf(URL source) {
191191 return Stream .empty ();
192192 }
193193 LOG .debug ("Scanning {} for dependencies" , source );
194- val path = source .getPath ();
194+ val fileName = source .getFile ();
195195 val output = new ArrayList <URL >();
196- if (path .endsWith (".jar" ) || path . endsWith ( ".zip " )) {
196+ if (fileName .endsWith (".jar" )) {
197197 //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 ) {
202201 if (!entry .getName ().startsWith ("META-INF" ) || !entry .getName ().endsWith (".json" )) {
203202 continue ;
204203 }
@@ -209,12 +208,12 @@ private static Stream<URL> scanSourceMetaInf(URL source) {
209208 }
210209 }
211210 } catch (IOException e ) {
212- LOG .error ("Failed to open jar file {}" , path );
211+ LOG .error ("Failed to open jar file {}" , source . getPath () );
213212 }
214213 } else {
215- val dir = new File (path );
214+ val dir = new File (fileName );
216215 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 );
218217 return Stream .empty ();
219218 }
220219 //Scan directory for json in META-INF, add them to the list
0 commit comments