Skip to content

Commit

Permalink
improved file changes watch
Browse files Browse the repository at this point in the history
When two URI are pointing to the same file, example:

@sources({
"${catalina.home}/conf/foobar.properties",
"${catalina.base}/conf/foobar.properties"
})

if ${catalina.home} == ${catalina.base} they may point to the same resource.

In this case, we are using two WatchableFile instance to check the same file, even though it is the same file.

This change is intended to recognize that the two File objects are pointing to the same instance and handle as a single WatchableFile.
  • Loading branch information
Luigi R. Viggiano committed Feb 4, 2015
1 parent 54658ac commit ff20e11
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion owner/src/main/java/org/aeonbits/owner/HotReloadLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import static org.aeonbits.owner.Config.HotReloadType.ASYNC;
import static org.aeonbits.owner.Config.HotReloadType.SYNC;
Expand Down Expand Up @@ -59,11 +61,14 @@ public HotReloadLogic(HotReload hotReload, List<URI> uris, PropertiesManager man
}

private void setupWatchableResources(List<URI> uris) {
Set<File> files = new LinkedHashSet<File>();
for (URI uri : uris) {
File file = fileFromURI(uri);
if (file != null)
watchableFiles.add(new WatchableFile(file));
files.add(file);
}
for (File file : files)
watchableFiles.add(new WatchableFile(file));
}

synchronized void checkAndReload() {
Expand Down

0 comments on commit ff20e11

Please sign in to comment.