3333import org .springframework .boot .devtools .restart .classloader .ClassLoaderFile .Kind ;
3434import org .springframework .boot .devtools .restart .classloader .ClassLoaderFileURLStreamHandler ;
3535import org .springframework .boot .devtools .restart .classloader .ClassLoaderFiles ;
36- import org .springframework .boot .devtools .restart .classloader .ClassLoaderFiles .SourceDirectory ;
3736import org .springframework .context .ApplicationContext ;
3837import org .springframework .context .support .AbstractApplicationContext ;
3938import org .springframework .core .io .AbstractResource ;
@@ -125,15 +124,13 @@ public Resource[] getResources(String locationPattern) throws IOException {
125124 private List <Resource > getAdditionalResources (String locationPattern ) throws MalformedURLException {
126125 List <Resource > additionalResources = new ArrayList <>();
127126 String trimmedLocationPattern = trimLocationPattern (locationPattern );
128- for (SourceDirectory sourceDirectory : this .classLoaderFiles .getSourceDirectories ()) {
129- for (Entry <String , ClassLoaderFile > entry : sourceDirectory .getFilesEntrySet ()) {
130- String name = entry .getKey ();
131- ClassLoaderFile file = entry .getValue ();
132- if (file .getKind () != Kind .DELETED && this .antPathMatcher .match (trimmedLocationPattern , name )) {
133- URL url = new URL ("reloaded" , null , -1 , "/" + name , new ClassLoaderFileURLStreamHandler (file ));
134- UrlResource resource = new UrlResource (url );
135- additionalResources .add (resource );
136- }
127+ for (Entry <String , ClassLoaderFile > entry : this .classLoaderFiles .getFileEntries ()) {
128+ String name = entry .getKey ();
129+ ClassLoaderFile file = entry .getValue ();
130+ if (file .getKind () != Kind .DELETED && this .antPathMatcher .match (trimmedLocationPattern , name )) {
131+ URL url = new URL ("reloaded" , null , -1 , "/" + name , new ClassLoaderFileURLStreamHandler (file ));
132+ UrlResource resource = new UrlResource (url );
133+ additionalResources .add (resource );
137134 }
138135 }
139136 return additionalResources ;
@@ -149,20 +146,18 @@ private String trimLocationPattern(String pattern) {
149146 }
150147
151148 private boolean isDeleted (Resource resource ) {
152- for (SourceDirectory sourceDirectory : this .classLoaderFiles .getSourceDirectories ()) {
153- for (Entry <String , ClassLoaderFile > entry : sourceDirectory .getFilesEntrySet ()) {
154- try {
155- String name = entry .getKey ();
156- ClassLoaderFile file = entry .getValue ();
157- if (file .getKind () == Kind .DELETED && resource .exists ()
158- && resource .getURI ().toString ().endsWith (name )) {
159- return true ;
160- }
161- }
162- catch (IOException ex ) {
163- throw new IllegalStateException ("Failed to retrieve URI from '" + resource + "'" , ex );
149+ for (Entry <String , ClassLoaderFile > entry : this .classLoaderFiles .getFileEntries ()) {
150+ try {
151+ String name = entry .getKey ();
152+ ClassLoaderFile file = entry .getValue ();
153+ if (file .getKind () == Kind .DELETED && resource .exists ()
154+ && resource .getURI ().toString ().endsWith (name )) {
155+ return true ;
164156 }
165157 }
158+ catch (IOException ex ) {
159+ throw new IllegalStateException ("Failed to retrieve URI from '" + resource + "'" , ex );
160+ }
166161 }
167162 return false ;
168163 }
0 commit comments