Update tests to use Files.createSymbolicLink() instead of
Runtime.getRuntime().exec() to create symbolic link fixtures.
Also fixes two CodeQL issues.
MODIFY
src/test/java/org/apache/commons/io/FileUtilsTest.java
src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -190,19 +190,8 @@ private void consumeRemaining(final Iterator<File> iterator) {
}
}
- private void createCircularOsSymLink(final String linkName, final String targetName) throws IOException {
- if (FilenameUtils.isSystemWindows()) {
- // Windows
- try {
- Runtime.getRuntime().exec("mklink /D " + linkName + " " + targetName);
- } catch (final IOException ioe) {
- // So that tests run in FAT filesystems don't fail
- ioe.printStackTrace();
- }
- } else {
- // Not Windows, assume Linux
- Runtime.getRuntime().exec("ln -s " + targetName + " " + linkName);
- }
+ private Path createCircularOsSymLink(final String linkName, final String targetName) throws IOException {
+ return Files.createSymbolicLink(Paths.get(linkName), Paths.get(targetName));
}
/**

Update tests to use Files.createSymbolicLink() instead of
Runtime.getRuntime().exec() to create symbolic link fixtures.

Also fixes two CodeQL issues.