4792059: test/java/io/pathNames/GeneralSolaris.java fails on symbolic links
authordxu
Thu, 29 Aug 2013 10:43:46 -0700
changeset 19611 0c8d4fbae4f2
parent 19610 2073a59a2787
child 19612 347df39afea6
child 19790 d97d46e9bddf
4792059: test/java/io/pathNames/GeneralSolaris.java fails on symbolic links Summary: Exclude the possible usage of linked files or directories in the test Reviewed-by: alanb
jdk/test/java/io/pathNames/General.java
--- a/jdk/test/java/io/pathNames/General.java	Thu Aug 29 11:22:44 2013 +0200
+++ b/jdk/test/java/io/pathNames/General.java	Thu Aug 29 10:43:46 2013 -0700
@@ -28,6 +28,7 @@
 
 import java.io.*;
 import java.util.*;
+import java.nio.file.*;
 
 
 public class General {
@@ -57,7 +58,7 @@
         for (int i = 0; i < dl.length; i++) {
             File f = new File(subdir, dl[i]);
             File df = new File(dir, f.getPath());
-            if (df.exists() && df.isFile()) {
+            if (Files.isRegularFile(df.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 return f.getPath();
             }
         }
@@ -65,7 +66,7 @@
             File f = (subdir.length() == 0) ? new File(dl[i])
                                             : new File(subdir, dl[i]);
             File df = new File(dir, f.getPath());
-            if (df.exists() && df.isDirectory()) {
+            if (Files.isDirectory(df.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 String[] dl2 = df.list();
                 if (dl2 != null) {
                     String ff = findSomeFile(dir, f.getPath(), dl2);
@@ -90,7 +91,7 @@
         }
         for (int i = 0; i < dl.length; i++) {
             File f = new File(dir, dl[i]);
-            if (f.isFile()) {
+            if (Files.isRegularFile(f.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 return dl[i];
             }
         }
@@ -127,7 +128,7 @@
         }
         for (int i = 0; i < dl.length; i++) {
             File f = new File(d, dl[i]);
-            if (f.isDirectory()) {
+            if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                 String[] dl2 = f.list();
                 if (dl2 == null || dl2.length >= 250) {
                     /* Heuristic to avoid scanning huge directories */
@@ -314,7 +315,7 @@
 
         /* Normal name */
         if (f.exists()) {
-            if (f.isDirectory() && f.list() != null) {
+            if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS) && f.list() != null) {
                 if ((n = findSomeFile(ans, create)) != null)
                     checkSlashes(d, create, ans + n, ask + n);
                 if ((n = findSomeDir(ans, create)) != null)