@@ -83,8 +83,9 @@ public final Artifact resolve(URL resourceURL) {
8383 } else {
8484 artifactMetadataData = readArtifactMetadataDataFromArchiveFile (archiveFile );
8585 }
86- artifact = resolve (resourceURL , artifactMetadataData , classLoader );
87-
86+ if (artifactMetadataData != null ) {
87+ artifact = resolve (resourceURL , artifactMetadataData , classLoader );
88+ }
8889 } catch (IOException e ) {
8990 if (logger .isErrorEnabled ()) {
9091 logger .error ("The Artifact can't be resolved from the resource URL : {}" , resourceURL , e );
@@ -115,7 +116,7 @@ protected InputStream readArtifactMetadataDataFromArchiveFile(File archiveFile)
115116 @ Nullable
116117 protected InputStream readArtifactMetadataDataFromFile (File archiveFile ) throws IOException {
117118 JarFile jarFile = new JarFile (archiveFile );
118- JarEntry jarEntry = resolveArtifactMetadataEntry (jarFile );
119+ JarEntry jarEntry = findArtifactMetadataEntry (jarFile );
119120 if (jarEntry == null ) {
120121 if (logger .isTraceEnabled ()) {
121122 logger .trace ("The artifact metadata entry can't be resolved from the JarFile[path: '{}']" , archiveFile );
@@ -127,8 +128,7 @@ protected InputStream readArtifactMetadataDataFromFile(File archiveFile) throws
127128
128129 @ Nullable
129130 protected InputStream readArtifactMetadataDataFromDirectory (File directory ) throws IOException {
130- Set <File > files = INSTANCE .scan (directory , true , file -> isArtifactMetadataFile (directory , file ));
131- File artifactMetadataFile = first (files );
131+ File artifactMetadataFile = findArtifactMetadata (directory );
132132 if (artifactMetadataFile == null ) {
133133 if (logger .isTraceEnabled ()) {
134134 logger .trace ("The artifact metadata file can't be found in the directory[path: '{}']" , directory );
@@ -138,11 +138,16 @@ protected InputStream readArtifactMetadataDataFromDirectory(File directory) thro
138138 return new FileInputStream (artifactMetadataFile );
139139 }
140140
141- protected JarEntry resolveArtifactMetadataEntry (JarFile jarFile ) throws IOException {
141+ protected JarEntry findArtifactMetadataEntry (JarFile jarFile ) throws IOException {
142142 List <JarEntry > entries = filter (jarFile , this ::isArtifactMetadataEntry );
143143 return first (entries );
144144 }
145145
146+ protected File findArtifactMetadata (File directory ) throws IOException {
147+ Set <File > files = INSTANCE .scan (directory , true , file -> isArtifactMetadataFile (directory , file ));
148+ return first (files );
149+ }
150+
146151 protected boolean isArtifactMetadataEntry (JarEntry jarEntry ) {
147152 return isArtifactMetadata (jarEntry .getName ());
148153 }
@@ -156,7 +161,7 @@ protected boolean isArtifactMetadata(String relativePath) {
156161 return false ;
157162 }
158163
159- protected abstract Artifact resolve (URL resourceURL , @ Nullable InputStream artifactMetadataData , ClassLoader classLoader ) throws IOException ;
164+ protected abstract Artifact resolve (URL resourceURL , InputStream artifactMetadataData , ClassLoader classLoader ) throws IOException ;
160165
161166 @ Override
162167 public final int getPriority () {
0 commit comments