Skip to content

Commit

Permalink
Obtaining parent dir for watcher service fixed (#4665)
Browse files Browse the repository at this point in the history
* Obtaining parent dir for watcher service fixed

Signed-off-by: David Kral <david.k.kral@oracle.com>
  • Loading branch information
Verdent authored Aug 3, 2022
1 parent bd3909e commit d91e8ae
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -209,7 +209,7 @@ private Monitor(Consumer<ChangeEvent<Path>> listener,
this.watchServiceModifiers = watchServiceModifiers;
this.fileExists = Files.exists(target);
this.watchingFile = !Files.isDirectory(target);
this.watchedDir = watchingFile ? target.getParent() : target;
this.watchedDir = watchingFile ? parentDir(target) : target;
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -342,7 +342,7 @@ private Path target(Path path) throws IOException {
}

private Path parentDir(Path path) {
Path parent = path.getParent();
Path parent = path.toAbsolutePath().getParent();
if (parent == null) {
throw new ConfigException(
String.format("Cannot find parent directory for '%s' to register watch service.", path));
Expand Down

0 comments on commit d91e8ae

Please sign in to comment.