Skip to content

Commit

Permalink
Merge pull request eclipse-efx#171 from aalmiray/watch-service
Browse files Browse the repository at this point in the history
Create a `WatchService` using a matching `FileSystem`
  • Loading branch information
tomsontom authored Nov 10, 2017
2 parents 016bcde + c5aa2fd commit c2efc8d
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 c2efc8d

Please sign in to comment.