Java 类java.nio.file.FileSystemLoopException 实例源码

项目:elasticsearch_my    文件:ExceptionSerializationTests.java   
public void testFileSystemExceptions() throws IOException {
    for (FileSystemException ex : Arrays.asList(new FileSystemException("a", "b", "c"),
        new NoSuchFileException("a", "b", "c"),
        new NotDirectoryException("a"),
        new DirectoryNotEmptyException("a"),
        new AtomicMoveNotSupportedException("a", "b", "c"),
        new FileAlreadyExistsException("a", "b", "c"),
        new AccessDeniedException("a", "b", "c"),
        new FileSystemLoopException("a"))) {

        FileSystemException serialize = serialize(ex);
        assertEquals(serialize.getClass(), ex.getClass());
        assertEquals("a", serialize.getFile());
        if (serialize.getClass() == NotDirectoryException.class ||
            serialize.getClass() == FileSystemLoopException.class ||
            serialize.getClass() == DirectoryNotEmptyException.class) {
            assertNull(serialize.getOtherFile());
            assertNull(serialize.getReason());
        } else {
            assertEquals(serialize.getClass().toString(), "b", serialize.getOtherFile());
            assertEquals(serialize.getClass().toString(), "c", serialize.getReason());
        }
    }
}
项目:jdk8u-jdk    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:openjdk-jdk10    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:openjdk9    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:jdk8u_jdk    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:infobip-open-jdk-8    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:jdk8u-dev-jdk    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:OLD-OpenJDK8    文件:StreamTest.java   
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
项目:n4js    文件:FileCopier.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) {
    if (exc instanceof FileSystemLoopException) {
        LOGGER.error("File system loop/cycle detected: " + file, exc);
    } else {
        LOGGER.error("Error while copying resource: " + file, exc);
    }
    return CONTINUE;
}
项目:marathonv5    文件:Copy.java   
@Override public FileVisitResult visitFileFailed(Path file, IOException exc) {
    if (exc instanceof FileSystemLoopException) {
        System.err.println("cycle detected: " + file);
    } else {
        System.err.format("Unable to copy: %s: %s%n", file, exc);
    }
    return CONTINUE;
}
项目:chipKIT-importer    文件:CopyingFileVisitor.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) {
    if (exc instanceof FileSystemLoopException) {
        LOGGER.log( Level.WARNING, "Cycle detected: " + file, exc );
    } else {
        LOGGER.log( Level.WARNING, "Unable to copy: " + file, exc );
    }
    return CONTINUE;
}
项目:mycore    文件:MCRTreeCopier.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) {
    if (exc instanceof FileSystemLoopException) {
        LOGGER.error("cycle detected: {}", file);
    } else {
        LOGGER.error("Unable to copy: {}", file, exc);
    }
    return FileVisitResult.CONTINUE;
}
项目:Processing.R    文件:TreeCopier.java   
@Override
public FileVisitResult visitFileFailed(final Path file, final IOException exc) {
  if (exc instanceof FileSystemLoopException) {
    System.err.println("cycle detected: " + file);
  } else {
    System.err.format("Unable to copy: %s: %s%n", file, exc);
  }
  return CONTINUE;
}
项目:easyrec_major    文件:TreeCopy.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException ioe) throws IOException {
    if (ioe instanceof FileSystemLoopException) {
        logger.error("cycle detected: " + file);
    } else {
        logger.error("Unable to copy: " + file, ioe);
    }
    return CONTINUE;
}
项目:ephemeralfs    文件:ResolvedPath.java   
public static ResolvedPath resolve(EphemeralFsPath path, boolean noFollowLastSymlink) throws FileSystemException {

    try {

        if(!path.isAbsolute()) {
            Path rootPath = path.getFileSystem().getRootPath();
            return resolve((EphemeralFsPath) rootPath.resolve(path), noFollowLastSymlink);
        }

        //if we look for existing/nonExistent/..
        //windows resolves this by skipping looking
        //up nonExistent, 
        //linux will fail though when it sees the nonExistent Directory
        if(!path.getFileSystem().getSettings().isPosix()) {
            path = path.normalize();
        }

        List<EphemeralFsPath> parts = new ArrayList<>(path.splitPaths());
        Collections.reverse(parts);
        List<ResolvedStep> steps = new ArrayList<>(parts.size());

        return resolveAbsolutePath(path, path.getFileSystem(), path.getFileSystem().getRoot(), parts, steps, noFollowLastSymlink);
    } catch(StackOverflowError e) {
        //recursive links
        throw new FileSystemLoopException(path +  ": Too many levels of symbolic links");
    }
}
项目:Fusion    文件:FileSystem.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException exception) throws IOException {
    if (exception instanceof FileSystemLoopException) {
        Engine.getLogger().log(Level.SEVERE, "Cycle detected: " + relativise(file), exception);
    } else {
        Engine.getLogger().log(Level.SEVERE, "Unable to copy: " + relativise(file), exception);
    }
    return CONTINUE;
}
项目:Starbound-Mod-Manager    文件:FileCopier.java   
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) {
    if (exc instanceof FileSystemLoopException) {
        log.error("cycle detected: " + file);
    } else {
        log.error(String.format("Unable to copy: %s: %s%n", file, exc));
    }
    return CONTINUE;
}
项目:buck    文件:DefaultProjectFilesystem.java   
private void ensureNoLoops(Path p, BasicFileAttributes attrs) throws FileSystemLoopException {
  if (!followLinks) {
    return;
  }
  if (!attrs.isDirectory()) {
    return;
  }
  if (willLoop(p, attrs)) {
    throw new FileSystemLoopException(p.toString());
  }
}