pull/5648/merge
Phillip Webb 9 years ago
parent 7709352c2d
commit 6d23ce2ada

@ -66,20 +66,16 @@ public abstract class ResourceUtils {
* @return a list of URLs
*/
public static List<String> getUrls(String path, ClassLoader classLoader) {
if (classLoader == null) {
classLoader = ClassUtils.getDefaultClassLoader();
}
path = StringUtils.cleanPath(path);
try {
return getUrlsFromWildcardPath(path, classLoader);
}
catch (Exception ex) {
throw new IllegalArgumentException(
"Cannot create URL from path [" + path + "]", ex);
}
}
@ -88,7 +84,6 @@ public abstract class ResourceUtils {
if (path.contains(":")) {
return getUrlsFromPrefixedWildcardPath(path, classLoader);
}
Set<String> result = new LinkedHashSet<String>();
try {
result.addAll(getUrls(FILE_URL_PREFIX + path, classLoader));
@ -96,7 +91,6 @@ public abstract class ResourceUtils {
catch (IllegalArgumentException ex) {
// ignore
}
path = stripLeadingSlashes(path);
result.addAll(getUrls(ALL_CLASSPATH_URL_PREFIX + path, classLoader));
return new ArrayList<String>(result);

@ -77,11 +77,17 @@ public class ClassPathFileSystemWatcherTests {
context.getEnvironment().getPropertySources().addLast(propertySource);
context.register(Config.class);
context.refresh();
Thread.sleep(100);
Thread.sleep(200);
File classFile = new File(folder, "Example.class");
FileCopyUtils.copy("file".getBytes(), classFile);
Thread.sleep(1100);
Thread.sleep(1000);
List<ClassPathChangedEvent> events = context.getBean(Listener.class).getEvents();
for (int i = 0; i < 20; i++) {
if (!events.isEmpty()) {
break;
}
Thread.sleep(500);
}
assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getChangeSet().iterator().next().getFiles().iterator()
.next().getFile()).isEqualTo(classFile);

Loading…
Cancel
Save