Skip to content

Commit

Permalink
Create a WatchService using a matching FileSystem instead of the …
Browse files Browse the repository at this point in the history
…default.

Signed-off-by: aalmiray <[email protected]>
  • Loading branch information
aalmiray committed Nov 9, 2017
1 parent 016bcde commit c5aa2fd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.ClosedWatchServiceException;
import java.nio.file.FileSystems;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardWatchEventKinds;
Expand Down Expand Up @@ -62,7 +62,7 @@ public Subscription observePath(URI uri, BiConsumer<Kind, URI> consumer) {
@Override
public Subscription observePath(Path path, BiConsumer<Kind, Path> consumer) {
if (this.thread == null || !this.thread.isAlive()) {
this.thread = new CheckThread();
this.thread = new CheckThread(path.getFileSystem());
this.thread.start();
}
try {
Expand All @@ -78,10 +78,10 @@ static class CheckThread extends Thread {
private final Executor dispatcher = Executors.newCachedThreadPool();
private final Thread shutdownCleanup;

public CheckThread() {
public CheckThread(FileSystem fileSystem) {
setDaemon(true);
try {
this.watcher = FileSystems.getDefault().newWatchService();
this.watcher = fileSystem.newWatchService();
} catch (IOException e) {
throw new IllegalStateException();
}
Expand Down

0 comments on commit c5aa2fd

Please sign in to comment.