This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
The following commit(s) were added to refs/heads/master by this push:
new 468c214 remove and cleanup unused code (#159)
468c214 is described below
commit 468c2146bd8ca8e157e20c93c4a317e161b78438
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Tue Jun 20 10:07:56 2023 +0000
remove and cleanup unused code (#159)
* remove and cleanup unused code
---
.../maven/shared/utils/io/DirectoryScanner.java | 48 +++++-----------------
.../shared/utils/io/DirectoryScannerTest.java | 6 ---
2 files changed, 11 insertions(+), 43 deletions(-)
diff --git
a/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
b/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
index 3c613ab..4eb9f31 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
@@ -22,7 +22,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
@@ -569,8 +568,6 @@ public class DirectoryScanner {
* the problematic code, as it appears to come from a native
method in UnixFileSystem...
*/
newfiles = new String[0];
-
- // throw new IOException( "IO error scanning directory " +
dir.getAbsolutePath() );
}
if (!followSymlinks) {
@@ -665,37 +662,29 @@ public class DirectoryScanner {
}
}
- private String[] doNotFollowSymbolicLinks(final File dir, final String
vpath, String[] newfiles) {
+ private String[] doNotFollowSymbolicLinks(final File dir, final String
vpath, final String[] newfiles) {
final List<String> noLinks = new ArrayList<String>();
for (final String newfile : newfiles) {
- try {
- if (isSymbolicLink(dir, newfile)) {
- final String name = vpath + newfile;
- final File file = new File(dir, newfile);
- if (file.isDirectory()) {
- dirsExcluded.add(name);
- } else {
- filesExcluded.add(name);
- }
+ if (Files.isSymbolicLink(dir.toPath())) {
+ final String name = vpath + newfile;
+ final File file = new File(dir, newfile);
+ if (file.isDirectory()) {
+ dirsExcluded.add(name);
} else {
- noLinks.add(newfile);
+ filesExcluded.add(name);
}
- } catch (final IOException ioe) {
- final String msg = "IOException caught while checking " + "for
links, couldn't get canonical path!";
- // will be caught and redirected to Ant's logging system
- System.err.println(msg);
+ } else {
noLinks.add(newfile);
}
}
- newfiles = noLinks.toArray(new String[noLinks.size()]);
- return newfiles;
+ return noLinks.toArray(new String[noLinks.size()]);
}
/**
- * Tests whether or not a name matches against at least one include
pattern.
+ * Tests whether or not a name matches at least one include pattern.
*
* @param name The name to match. Must not be <code>null</code>.
- * @return <code>true</code> when the name matches against at least one
include pattern, or <code>false</code>
+ * @return <code>true</code> when the name matches at least one include
pattern, or <code>false</code>
* otherwise.
*/
boolean isIncluded(final String name) {
@@ -822,21 +811,6 @@ public class DirectoryScanner {
excludes = newExcludes;
}
- /**
- * Checks whether a given file is a symbolic link.
- * <p>
- * It doesn't really test for symbolic links but whether the canonical and
absolute paths of the file are identical
- * - this may lead to false positives on some platforms.
- * </p>
- *
- * @param parent the parent directory of the file to test
- * @param name the name of the file to test.
- *
- */
- boolean isSymbolicLink(final File parent, final String name) throws
IOException {
- return Files.isSymbolicLink(parent.toPath());
- }
-
private void setupDefaultFilters() {
if (includes == null) {
// No includes supplied, so set it to 'matches all'
diff --git
a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
index 272cc65..74a3f32 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
@@ -276,12 +276,6 @@ public class DirectoryScannerTest {
/* expExclDirs */ NONE);
}
- public void testIsSymbolicLink() throws IOException {
- File file = new File(".");
- DirectoryScanner ds = new DirectoryScanner();
- ds.isSymbolicLink(file, "abc");
- }
-
/**
* Performs a scan and test for the given parameters if not null.
*/