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

下面列出了怎么用java.nio.file.FileSystemLoopException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_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);
    }
}
 
源代码2 项目: TencentKona-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);
    }
}
 
源代码3 项目: jdk8u60   文件: 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);
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: 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);
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: 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);
    }
}
 
源代码6 项目: openjdk-jdk9   文件: 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);
    }
}
 
源代码7 项目: 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);
    }
}
 
源代码8 项目: hottub   文件: 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);
    }
}
 
源代码9 项目: openjdk-8-source   文件: 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);
    }
}
 
源代码10 项目: openjdk-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);
    }
}
 
源代码11 项目: 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);
    }
}
 
源代码12 项目: 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);
    }
}
 
源代码13 项目: 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);
    }
}
 
源代码14 项目: genie   文件: DirectoryManifest.java
/**
 * {@inheritDoc}
 */
@Override
public FileVisitResult visitFileFailed(final Path file, final IOException ioe) {
    if (ioe instanceof FileSystemLoopException) {
        log.warn("Detected file system cycle visiting while visiting {}. Skipping.", file);
        return FileVisitResult.SKIP_SUBTREE;
    } else if (ioe instanceof AccessDeniedException) {
        log.warn("Access denied for file {}. Skipping", file);
        return FileVisitResult.SKIP_SUBTREE;
    } else if (ioe instanceof NoSuchFileException) {
        log.warn("File or directory disappeared while visiting {}. Skipping", file);
        return FileVisitResult.SKIP_SUBTREE;
    } else {
        log.error("Got unknown error {} while visiting {}. Terminating visitor", ioe.getMessage(), file, ioe);
        // TODO: Not sure if we should do this or skip subtree or just continue and ignore it?
        return FileVisitResult.TERMINATE;
    }
}
 
源代码15 项目: Java-Coding-Problems   文件: CopyFileVisitor.java
@Override
public FileVisitResult visitFileFailed(Object file, IOException ioe) throws IOException {

    if (ioe instanceof FileSystemLoopException) {
        System.err.println("Cycle was detected: " + (Path) file);
    } else {
        System.err.println("Error occured, unable to copy:" + (Path) file + " [" + ioe + "]");
    }

    return FileVisitResult.CONTINUE;
}
 
源代码16 项目: 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;
}
 
源代码17 项目: 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;
}
 
源代码18 项目: 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;
}
 
源代码19 项目: 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;
}
 
源代码20 项目: studio   文件: TreeCopier.java
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
    if (exc instanceof FileSystemLoopException) {
        logger.error("cycle detected: " + file);
    } else {
        logger.error("Unable to copy: %s: %s%n", file, exc);
    }
    return CONTINUE;
}
 
源代码21 项目: buck   文件: ExceptionHandlerRegistryFactory.java
@Override
public ExitCode handleException(IOException e) {
  if (e instanceof FileSystemLoopException) {
    return ExitCode.FATAL_GENERIC;
  } else if (e.getMessage() != null
      && e.getMessage().startsWith("No space left on device")) {
    return ExitCode.FATAL_DISK_FULL;
  } else {
    return ExitCode.FATAL_IO;
  }
}
 
源代码22 项目: 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());
  }
}
 
源代码23 项目: buck   文件: ErrorLoggerTest.java
@Test
public void testFileSystemLoopException() {
  LoggedErrors errors =
      logException(new TestException(new FileSystemLoopException("It's a loop!")));

  assertNull(errors.userVisible);
  assertThat(
      errors.userVisibleInternal,
      Matchers.containsString(
          "Loop detected in your directory, which may be caused by circular symlink. "
              + "You may consider running the command in a smaller directory."));
  assertThat(
      errors.userVisibleInternal,
      Matchers.containsString("java.nio.file.FileSystemLoopException: It's a loop!"));
}
 
源代码24 项目: buck   文件: ErrorLogger.java
/** Returns the message (and optionally stack trace) for the root cause. */
public String getMessage(boolean suppressStackTraces) {
  if (rootCause instanceof HumanReadableException) {
    return ((HumanReadableException) rootCause).getHumanReadableErrorMessage();
  }

  if (rootCause instanceof InterruptedException
      || rootCause instanceof ClosedByInterruptException) {
    return "Interrupted";
  }

  if (rootCause instanceof BuckIsDyingException) {
    return "Failed because buck was already dying";
  }

  if (isNoSpaceOnDevice()) {
    return rootCause.getMessage();
  }

  String message = "";
  if (rootCause instanceof FileSystemLoopException) {
    // TODO(cjhopman): Is this message helpful? What's a smaller directory?
    message =
        "Loop detected in your directory, which may be caused by circular symlink. "
            + "You may consider running the command in a smaller directory."
            + System.lineSeparator();
  }

  if (rootCause instanceof OutOfMemoryError) {
    message =
        "Buck ran out of memory, you may consider increasing heap size with java args "
            + "(see https://buck.build/files-and-dirs/buckjavaargs.html)"
            + System.lineSeparator();
  }

  if (suppressStackTraces) {
    return String.format(
        "%s%s: %s", message, rootCause.getClass().getName(), rootCause.getMessage());
  }

  return String.format("%s%s", message, Throwables.getStackTraceAsString(originalException));
}
 
源代码25 项目: buck   文件: ExceptionHandlerRegistryTest.java
@Test
public void testWithFileLoopException() {
  assertThat(
      registry.handleException(new FileSystemLoopException("Symlink found")),
      is(ExitCode.FATAL_GENERIC));
}
 
 类所在包
 同包方法