java.nio.file.FileSystemLoopException Java Examples
The following examples show how to use
java.nio.file.FileSystemLoopException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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); } }
Example #2
Source File: DirectoryManifest.java From genie with Apache License 2.0 | 6 votes |
/** * {@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; } }
Example #3
Source File: StreamTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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); } }
Example #4
Source File: StreamTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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); } }
Example #5
Source File: StreamTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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); } }
Example #6
Source File: StreamTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #7
Source File: StreamTest.java From hottub with GNU General Public License v2.0 | 6 votes |
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); } }
Example #8
Source File: StreamTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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); } }
Example #9
Source File: StreamTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #10
Source File: StreamTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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); } }
Example #11
Source File: StreamTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #12
Source File: StreamTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #13
Source File: StreamTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } }
Example #14
Source File: StreamTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); } }
Example #15
Source File: MCRTreeCopier.java From mycore with GNU General Public License v3.0 | 5 votes |
@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; }
Example #16
Source File: FileCopier.java From n4js with Eclipse Public License 1.0 | 5 votes |
@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; }
Example #17
Source File: CopyFileVisitor.java From Java-Coding-Problems with MIT License | 5 votes |
@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; }
Example #18
Source File: Copy.java From marathonv5 with Apache License 2.0 | 5 votes |
@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; }
Example #19
Source File: TreeCopier.java From Processing.R with GNU General Public License v3.0 | 5 votes |
@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; }
Example #20
Source File: TreeCopier.java From studio with GNU General Public License v3.0 | 5 votes |
@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; }
Example #21
Source File: ExceptionHandlerRegistryFactory.java From buck with Apache License 2.0 | 5 votes |
@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; } }
Example #22
Source File: DefaultProjectFilesystem.java From buck with Apache License 2.0 | 5 votes |
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()); } }
Example #23
Source File: ErrorLoggerTest.java From buck with Apache License 2.0 | 5 votes |
@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!")); }
Example #24
Source File: ErrorLogger.java From buck with Apache License 2.0 | 4 votes |
/** 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)); }
Example #25
Source File: ExceptionHandlerRegistryTest.java From buck with Apache License 2.0 | 4 votes |
@Test public void testWithFileLoopException() { assertThat( registry.handleException(new FileSystemLoopException("Symlink found")), is(ExitCode.FATAL_GENERIC)); }