33
33
import org .springframework .boot .devtools .restart .classloader .ClassLoaderFile .Kind ;
34
34
import org .springframework .boot .devtools .restart .classloader .ClassLoaderFileURLStreamHandler ;
35
35
import org .springframework .boot .devtools .restart .classloader .ClassLoaderFiles ;
36
- import org .springframework .boot .devtools .restart .classloader .ClassLoaderFiles .SourceDirectory ;
37
36
import org .springframework .context .ApplicationContext ;
38
37
import org .springframework .context .support .AbstractApplicationContext ;
39
38
import org .springframework .core .io .AbstractResource ;
@@ -125,15 +124,13 @@ public Resource[] getResources(String locationPattern) throws IOException {
125
124
private List <Resource > getAdditionalResources (String locationPattern ) throws MalformedURLException {
126
125
List <Resource > additionalResources = new ArrayList <>();
127
126
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 );
137
134
}
138
135
}
139
136
return additionalResources ;
@@ -149,20 +146,18 @@ private String trimLocationPattern(String pattern) {
149
146
}
150
147
151
148
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 ;
164
156
}
165
157
}
158
+ catch (IOException ex ) {
159
+ throw new IllegalStateException ("Failed to retrieve URI from '" + resource + "'" , ex );
160
+ }
166
161
}
167
162
return false ;
168
163
}
0 commit comments