Skip to content

Commit d91e8ae

Browse files
authored
Obtaining parent dir for watcher service fixed (helidon-io#4665)
* Obtaining parent dir for watcher service fixed Signed-off-by: David Kral <david.k.kral@oracle.com>
1 parent bd3909e commit d91e8ae

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

config/config/src/main/java/io/helidon/config/FileSystemWatcher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -209,7 +209,7 @@ private Monitor(Consumer<ChangeEvent<Path>> listener,
209209
this.watchServiceModifiers = watchServiceModifiers;
210210
this.fileExists = Files.exists(target);
211211
this.watchingFile = !Files.isDirectory(target);
212-
this.watchedDir = watchingFile ? target.getParent() : target;
212+
this.watchedDir = watchingFile ? parentDir(target) : target;
213213
}
214214

215215
@SuppressWarnings("unchecked")
@@ -342,7 +342,7 @@ private Path target(Path path) throws IOException {
342342
}
343343

344344
private Path parentDir(Path path) {
345-
Path parent = path.getParent();
345+
Path parent = path.toAbsolutePath().getParent();
346346
if (parent == null) {
347347
throw new ConfigException(
348348
String.format("Cannot find parent directory for '%s' to register watch service.", path));

0 commit comments

Comments
 (0)