Polish
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user