src/share/classes/java/nio/file/FileTreeWalker.java

Print this page

        

@@ -100,16 +100,17 @@
         // attempt to get attributes of file. If fails and we are following
         // links then a link target might not exist so get attributes of link
         if (attrs == null) {
             try {
                 try {
-                    attrs = Attributes.readBasicFileAttributes(file, linkOptions);
+                    attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
                 } catch (IOException x1) {
                     if (followLinks) {
                         try {
-                            attrs = Attributes
-                                .readBasicFileAttributes(file, LinkOption.NOFOLLOW_LINKS);
+                            attrs = Files.readAttributes(file,
+                                                         BasicFileAttributes.class,
+                                                         LinkOption.NOFOLLOW_LINKS);
                         } catch (IOException x2) {
                             exc = x2;
                         }
                     } else {
                         exc = x1;

@@ -149,11 +150,11 @@
                             new FileSystemLoopException(file.toString()));
                     }
                 } else {
                     boolean isSameFile = false;
                     try {
-                        isSameFile = file.isSameFile(ancestor.file());
+                        isSameFile = Files.isSameFile(file, ancestor.file());
                     } catch (IOException x) {
                         // ignore
                     } catch (SecurityException x) {
                         // ignore
                     }

@@ -173,11 +174,11 @@
             DirectoryStream<Path> stream = null;
             FileVisitResult result;
 
             // open the directory
             try {
-                stream = file.newDirectoryStream();
+                stream = Files.newDirectoryStream(file);
             } catch (IOException x) {
                 return visitor.visitFileFailed(file, x);
             } catch (SecurityException x) {
                 // ignore, as per spec
                 return FileVisitResult.CONTINUE;

@@ -210,12 +211,16 @@
                     ioe = e.getCause();
                 }
             } finally {
                 try {
                     stream.close();
-                } catch (IOException x) { }
+                } catch (IOException e) {
+                    // IOException will be notified to postVisitDirectory
+                    if (ioe == null)
+                        ioe = e;
             }
+            }
 
             // invoke postVisitDirectory last
             return visitor.postVisitDirectory(file, ioe);
 
         } finally {