Skip to content

Commit 5e19181

Browse files
azakkermanVladimir Kotal
authored andcommitted
Catch all IOExceptions thrown by toRealPath and fallback to normalize().toAbsolutePath()
This is necessary, because getRelativeToCanonical is called for paths that are not real paths (e.g. in the case of reading git history and resolving historical paths relative to current)
1 parent 57d14d5 commit 5e19181

File tree

1 file changed

+1
-4
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/util

1 file changed

+1
-4
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/util/PathUtils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.nio.file.FileSystem;
2929
import java.nio.file.Files;
3030
import java.nio.file.InvalidPathException;
31-
import java.nio.file.NoSuchFileException;
3231
import java.nio.file.Path;
3332
import java.nio.file.Paths;
3433
import java.util.Deque;
@@ -96,8 +95,6 @@ public static String getRelativeToCanonical(Path path, Path canonical)
9695
* the explicit validation against {@code allowedSymlinks}.
9796
* @return a relative path determined as described above -- or {@code path}
9897
* if no canonical relativity is found
99-
* @throws IOException if an error occurs determining canonical paths
100-
* for portions of {@code path}
10198
* @throws ForbiddenSymlinkException if symbolic-link checking is active
10299
* and it encounters an ineligible link
103100
* @throws InvalidPathException if path cannot be decoded
@@ -133,7 +130,7 @@ public static String getRelativeToCanonical(Path path, Path canonical,
133130
Path iterCanon;
134131
try {
135132
iterCanon = iterPath.toRealPath();
136-
} catch (NoSuchFileException e) {
133+
} catch (IOException e) {
137134
iterCanon = iterPath.normalize().toAbsolutePath();
138135
}
139136

0 commit comments

Comments
 (0)