Java Code Examples for java.nio.file.NoSuchFileException

The following examples show how to use java.nio.file.NoSuchFileException. These examples are extracted from open source projects. 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 Project: hadoop-ozone   Source File: ChunkUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static ContainerProtos.Result translate(Exception cause) {
  if (cause instanceof FileNotFoundException ||
      cause instanceof NoSuchFileException) {
    return UNABLE_TO_FIND_CHUNK;
  }

  if (cause instanceof IOException) {
    return IO_EXCEPTION;
  }

  if (cause instanceof NoSuchAlgorithmException) {
    return NO_SUCH_ALGORITHM;
  }

  return CONTAINER_INTERNAL_ERROR;
}
 
Example 2
Source Project: crate   Source File: BlobStoreRepository.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the latest snapshot index blob id.  Snapshot index blobs are named index-N, where N is
 * the next version number from when the index blob was written.  Each individual index-N blob is
 * only written once and never overwritten.  The highest numbered index-N blob is the latest one
 * that contains the current snapshots in the repository.
 *
 * Package private for testing
 */
long latestIndexBlobId() throws IOException {
    try {
        // First, try listing all index-N blobs (there should only be two index-N blobs at any given
        // time in a repository if cleanup is happening properly) and pick the index-N blob with the
        // highest N value - this will be the latest index blob for the repository.  Note, we do this
        // instead of directly reading the index.latest blob to get the current index-N blob because
        // index.latest is not written atomically and is not immutable - on every index-N change,
        // we first delete the old index.latest and then write the new one.  If the repository is not
        // read-only, it is possible that we try deleting the index.latest blob while it is being read
        // by some other operation (such as the get snapshots operation).  In some file systems, it is
        // illegal to delete a file while it is being read elsewhere (e.g. Windows).  For read-only
        // repositories, we read for index.latest, both because listing blob prefixes is often unsupported
        // and because the index.latest blob will never be deleted and re-written.
        return listBlobsToGetLatestIndexId();
    } catch (UnsupportedOperationException e) {
        // If its a read-only repository, listing blobs by prefix may not be supported (e.g. a URL repository),
        // in this case, try reading the latest index generation from the index.latest blob
        try {
            return readSnapshotIndexLatestBlob();
        } catch (NoSuchFileException nsfe) {
            return RepositoryData.EMPTY_REPO_GEN;
        }
    }
}
 
Example 3
Source Project: singer   Source File: FileSystemMonitor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Handle the modified event. We can ignore the changes in watermark files that
 * starts with '.' character.
 * @throws IOException
 */
private void handleEntryModifyEvent(Path logDir , Path modified ) throws IOException {
  Path fullPath = logDir.resolve(modified);
  long inode;
  try {
    inode = SingerUtils.getFileInode(fullPath);
  } catch(NoSuchFileException e) {
    LOG.warn("Failed to get inode info for " + fullPath, e);
    return;
  }

  List<LogStream> logStreams = LogStreamManager.getLogStreamsFor(logDir, fullPath);
  for (LogStream stream : logStreams) {
    if (stream != null) {
      stream.append(new LogFile(inode), fullPath.toString());
    } else if (!modified.toString().startsWith(".")) {
      LOG.debug("Found a file {} that is not in any log stream", modified);
    }
  }
}
 
Example 4
Source Project: rdf-delta   Source File: S_Data.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void executeAction(DeltaAction action) throws IOException {
    LOG.info("GET "+action.getURL());
    Id dsRef = Id.fromString(action.httpArgs.datasourceName);
    String filenameIRI = determineData(action, dsRef);
    ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
    String fn = IRILib.IRIToFilename(filenameIRI);
    Path path = Paths.get(fn);
    try ( InputStream in = Files.newInputStream(path) ) {
        action.response.setStatus(HttpSC.OK_200);
        action.response.setContentType(ct.getContentTypeStr());
        IOUtils.copy(in, action.response.getOutputStream());
    } catch (NoSuchFileException | FileNotFoundException ex) {
        throw new DeltaNotFoundException(action.getURL());
    }
}
 
Example 5
Source Project: buck   Source File: StackedFileHashCacheTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void skipsFirstCacheBecauseIgnoredForArchiveMemberPathAbsolutePath() throws IOException {
  Config config = ConfigBuilder.createFromText("[project]", "ignore = world.jar");
  Path fullPath = Paths.get("world.jar");
  ProjectFilesystem filesystem =
      TestProjectFilesystems.createProjectFilesystem(tmp.getRoot(), config);
  writeJarWithHashes(filesystem, filesystem.resolve(fullPath));
  ArchiveMemberPath archiveMemberPath =
      ArchiveMemberPath.of(filesystem.resolve(fullPath), Paths.get("Nonexistent.class"));
  ProjectFileHashCache innerCache =
      DefaultFileHashCache.createDefaultFileHashCache(filesystem, fileHashCacheMode);
  StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
  expectedException.expect(NoSuchFileException.class);
  cache.getForArchiveMember(
      archiveMemberPath.getArchivePath(), archiveMemberPath.getMemberPath());
}
 
Example 6
Source Project: datakernel   Source File: Cube.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Promise<QueryResult> query(CubeQuery cubeQuery) throws QueryException {
	DefiningClassLoader queryClassLoader = getQueryClassLoader(new CubeClassLoaderCache.Key(
			new LinkedHashSet<>(cubeQuery.getAttributes()),
			new LinkedHashSet<>(cubeQuery.getMeasures()),
			cubeQuery.getWhere().getDimensions()));
	long queryStarted = eventloop.currentTimeMillis();
	return new RequestContext<>().execute(queryClassLoader, cubeQuery)
			.whenComplete((queryResult, e) -> {
				if (e == null) {
					queryTimes.recordValue((int) (eventloop.currentTimeMillis() - queryStarted));
				} else {
					queryErrors++;
					queryLastError = e;

					if (e instanceof NoSuchFileException) {
						logger.warn("Query failed because of NoSuchFileException. " + cubeQuery.toString(), e);
					}
				}
			});
}
 
Example 7
Source Project: InflatableDonkey   Source File: DiskChunk.java    License: MIT License 6 votes vote down vote up
Optional<InputStream> doInputStream() throws IOException {
    try {
        InputStream is = Files.newInputStream(file, READ);
        if (logger.isTraceEnabled()) {
            logger.trace("-- doInputStream() - open: {}", Hex.toHexString(checksum()));
            IOConsumer<InputStream> callback = u
                    -> logger.trace("-- doInputStream() - callback close: {}", Hex.toHexString(checksum()));
            is = new HookInputStream(is, callback);
        }
        return Optional.of(is);

    } catch (NoSuchFileException ex) {
        logger.warn("-- doInputStream() - file was just deleted: {}", ex);
        return Optional.empty();
    }
}
 
Example 8
Source Project: pravega   Source File: FileSystemStorage.java    License: Apache License 2.0 6 votes vote down vote up
private <T> T throwException(String segmentName, Exception e) throws StreamSegmentException {
    if (e instanceof NoSuchFileException || e instanceof FileNotFoundException) {
        throw new StreamSegmentNotExistsException(segmentName);
    }

    if (e instanceof FileAlreadyExistsException) {
        throw new StreamSegmentExistsException(segmentName);
    }

    if (e instanceof IndexOutOfBoundsException) {
        throw new IllegalArgumentException(e.getMessage());
    }

    if (e instanceof AccessControlException
            || e instanceof AccessDeniedException
            || e instanceof NonWritableChannelException) {
        throw new StreamSegmentSealedException(segmentName, e);
    }

    throw Exceptions.sneakyThrow(e);
}
 
Example 9
Source Project: flink   Source File: LocalFileSystem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean rename(final Path src, final Path dst) throws IOException {
	final File srcFile = pathToFile(src);
	final File dstFile = pathToFile(dst);

	final File dstParent = dstFile.getParentFile();

	// Files.move fails if the destination directory doesn't exist
	//noinspection ResultOfMethodCallIgnored -- we don't care if the directory existed or was created
	dstParent.mkdirs();

	try {
		Files.move(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
		return true;
	}
	catch (NoSuchFileException | AccessDeniedException | DirectoryNotEmptyException | SecurityException ex) {
		// catch the errors that are regular "move failed" exceptions and return false
		return false;
	}
}
 
Example 10
Source Project: jdk8u60   Source File: BlockDeviceSize.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    try (FileChannel ch = FileChannel.open(BLK_PATH, READ);
         RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) {

        long size1 = ch.size();
        long size2 = file.length();
        if (size1 != size2) {
            throw new RuntimeException("size differs when retrieved" +
                    " in different ways: " + size1 + " != " + size2);
        }
        System.out.println("OK");

    } catch (NoSuchFileException nsfe) {
        System.err.println("File " + BLK_FNAME + " not found." +
                " Skipping test");
    } catch (AccessDeniedException ade) {
        System.err.println("Access to " + BLK_FNAME + " is denied." +
                " Run test as root.");
    }
}
 
Example 11
Source Project: incubator-taverna-language   Source File: TestZipFS.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void setLastModifiedTime() throws Exception {
	Path root = fs.getRootDirectories().iterator().next();

	Path folder = root.resolve("folder");
	Files.createDirectory(folder);

	Path file = root.resolve("file");
	Files.createFile(file);

	FileTime someTimeAgo = FileTime.from(365 * 12, TimeUnit.DAYS);
	Files.setLastModifiedTime(folder, someTimeAgo);
	Files.setLastModifiedTime(file, someTimeAgo);
	try {
		Files.setLastModifiedTime(root, someTimeAgo);
	} catch (NoSuchFileException ex) {
		System.err
				.println("Unexpected failure of setLastModifiedTime on root");
		ex.printStackTrace();
	}
}
 
Example 12
Source Project: buck   Source File: AbstractBuildPackageComputationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Parameters(method = "getAnyPathParams")
public void throwsIfNamedDirectoryAncestorIsRegularFile(Kind kind, String targetName)
    throws ExecutionException, InterruptedException, IOException {
  filesystem.createNewFile(Paths.get("file"));

  BuildTargetPatternToBuildPackagePathKey key =
      key(CanonicalCellName.rootCell(), kind, "file/dir", targetName);

  thrown.expect(ExecutionException.class);
  thrown.expectCause(
      Matchers.anyOf(
          IsInstanceOf.instanceOf(NoSuchFileException.class),
          IsInstanceOf.instanceOf(NotDirectoryException.class)));
  transform("BUCK", key);
}
 
Example 13
Source Project: sftp-fs   Source File: SFTPFileSystem.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private SFTPAttributesAndOutputStreamPair newOutputStream(Channel channel, SFTPPath path, boolean requireAttributes, OpenOptions options)
        throws IOException {

    // retrieve the attributes unless create is true and createNew is false, because then the file can be created
    SftpATTRS attributes = null;
    if (!options.create || options.createNew) {
        attributes = findAttributes(channel, path, false);
        if (attributes != null && attributes.isDir()) {
            throw Messages.fileSystemProvider().isDirectory(path.path());
        }
        if (!options.createNew && attributes == null) {
            throw new NoSuchFileException(path.path());
        } else if (options.createNew && attributes != null) {
            throw new FileAlreadyExistsException(path.path());
        }
    }
    // else the file can be created if necessary

    if (attributes == null && requireAttributes) {
        attributes = findAttributes(channel, path, false);
    }

    OutputStream out = channel.newOutputStream(path.path(), options);
    return new SFTPAttributesAndOutputStreamPair(attributes, out);
}
 
Example 14
Source Project: mycore   Source File: MCRIView2Tools.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static int getImageType(Path iviewFileRoot, ImageReader imageReader, int zoomLevel, int x, int y)
    throws IOException {
    String tileName = new MessageFormat("{0}/{1}/{2}.jpg", Locale.ROOT).format(new Object[] { zoomLevel, y, x });
    Path tile = iviewFileRoot.resolve(tileName);
    if (Files.exists(tile)) {
        try (SeekableByteChannel fileChannel = Files.newByteChannel(tile)) {
            ImageInputStream iis = ImageIO.createImageInputStream(fileChannel);
            if (iis == null) {
                throw new IOException("Could not acquire ImageInputStream from SeekableByteChannel: " + tile);
            }
            imageReader.setInput(iis, true);
            int imageType = MCRImage.getImageType(imageReader);
            imageReader.reset();
            iis.close();
            return imageType;
        }
    } else {
        throw new NoSuchFileException(iviewFileRoot.toString(), tileName, null);
    }
}
 
Example 15
Source Project: Launcher   Source File: UnpackHelper.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static boolean unpackZipNoCheck(String resource, Path target) throws IOException {
    try {
        if (Files.isDirectory(target))
            return false;
        Files.deleteIfExists(target);
        Files.createDirectory(target);
        try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL(resource))) {
            for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) {
                if (entry.isDirectory())
                    continue; // Skip dirs
                // Unpack file
                IOHelper.transfer(input, target.resolve(IOHelper.toPath(entry.getName())));
            }
        }
        return true;
    } catch (NoSuchFileException e) {
        return true;
    }
}
 
Example 16
Source Project: buck   Source File: AppleToolchainDiscovery.java    License: Apache License 2.0 6 votes vote down vote up
private static void addIdentifierForToolchain(
    Path toolchainDir, ImmutableMap.Builder<String, AppleToolchain> identifierToToolchainBuilder)
    throws IOException {

  boolean addedToolchain = false;
  String[] potentialPlistNames = {"ToolchainInfo.plist", "Info.plist"};
  for (String plistName : potentialPlistNames) {
    try {
      Optional<AppleToolchain> toolchain = toolchainFromPlist(toolchainDir, plistName);
      if (toolchain.isPresent()) {
        identifierToToolchainBuilder.put(toolchain.get().getIdentifier(), toolchain.get());
        addedToolchain = true;
        break;
      }
    } catch (FileNotFoundException | NoSuchFileException e) {
      LOG.debug("Loading toolchain from plist %s for %s failed", plistName, toolchainDir);
    }
  }

  if (!addedToolchain) {
    LOG.debug(
        "Failed to resolve info about toolchain %s from plist files %s",
        toolchainDir.toString(), Arrays.toString(potentialPlistNames));
  }
}
 
Example 17
Source Project: jdk8u-jdk   Source File: BlockDeviceSize.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    try (FileChannel ch = FileChannel.open(BLK_PATH, READ);
         RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) {

        long size1 = ch.size();
        long size2 = file.length();
        if (size1 != size2) {
            throw new RuntimeException("size differs when retrieved" +
                    " in different ways: " + size1 + " != " + size2);
        }
        System.out.println("OK");

    } catch (NoSuchFileException nsfe) {
        System.err.println("File " + BLK_FNAME + " not found." +
                " Skipping test");
    } catch (AccessDeniedException ade) {
        System.err.println("Access to " + BLK_FNAME + " is denied." +
                " Run test as root.");
    }
}
 
Example 18
Source Project: lucene-solr   Source File: TestDirectoryReader.java    License: Apache License 2.0 6 votes vote down vote up
public void testOpenReaderAfterDelete() throws IOException {
  Path dirFile = createTempDir("deletetest");
  Directory dir = newFSDirectory(dirFile);
  if (dir instanceof BaseDirectoryWrapper) {
    ((BaseDirectoryWrapper)dir).setCheckIndexOnClose(false); // we will hit NoSuchFileException in MDW since we nuked it!
  }
  expectThrowsAnyOf(Arrays.asList(FileNotFoundException.class, NoSuchFileException.class),
      () -> DirectoryReader.open(dir)
  );

  IOUtils.rm(dirFile);

  // Make sure we still get a CorruptIndexException (not NPE):
  expectThrowsAnyOf(Arrays.asList(FileNotFoundException.class, NoSuchFileException.class),
      () -> DirectoryReader.open(dir)
  );
  
  dir.close();
}
 
Example 19
public static void main(String[] args) throws Throwable {
    try (FileChannel ch = FileChannel.open(BLK_PATH, READ);
         RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) {

        long size1 = ch.size();
        long size2 = file.length();
        if (size1 != size2) {
            throw new RuntimeException("size differs when retrieved" +
                    " in different ways: " + size1 + " != " + size2);
        }
        System.out.println("OK");

    } catch (NoSuchFileException nsfe) {
        System.err.println("File " + BLK_FNAME + " not found." +
                " Skipping test");
    } catch (AccessDeniedException ade) {
        System.err.println("Access to " + BLK_FNAME + " is denied." +
                " Run test as root.");
    }
}
 
Example 20
Source Project: genie   Source File: DirectoryManifest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@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 21
Source Project: cactoos   Source File: AppendToTest.java    License: MIT License 6 votes vote down vote up
/**
 * Ensures that AppendTo is failing on a negative predicate result.
 */
@Test
public void failsIfFileDoesNotExist() {
    final File source = new File(
        new Randomized(
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'
        ).asString()
    );
    new Assertion<>(
        "Can't throw exception with proper message",
        () -> new AppendTo(source).stream(),
        new Throws<>(
            source.getPath(),
            NoSuchFileException.class
        )
    ).affirm();
}
 
Example 22
Source Project: crate   Source File: BlobStoreRepository.java    License: Apache License 2.0 6 votes vote down vote up
private RepositoryData getRepositoryData(long indexGen) {
    if (indexGen == RepositoryData.EMPTY_REPO_GEN) {
        return RepositoryData.EMPTY;
    }
    try {
        final String snapshotsIndexBlobName = INDEX_FILE_PREFIX + Long.toString(indexGen);

        RepositoryData repositoryData;
        // EMPTY is safe here because RepositoryData#fromXContent calls namedObject
        try (InputStream blob = blobContainer().readBlob(snapshotsIndexBlobName);
             XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
                                                                               LoggingDeprecationHandler.INSTANCE, blob)) {
            repositoryData = RepositoryData.snapshotsFromXContent(parser, indexGen);
        }
        return repositoryData;
    } catch (NoSuchFileException ex) {
        // repository doesn't have an index blob, its a new blank repo
        return RepositoryData.EMPTY;
    } catch (IOException ioe) {
        throw new RepositoryException(metadata.name(), "could not read repository data from index blob", ioe);
    }
}
 
Example 23
public static void main(String[] args) throws Throwable {
    try (FileChannel ch = FileChannel.open(BLK_PATH, READ);
         RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) {

        long size1 = ch.size();
        long size2 = file.length();
        if (size1 != size2) {
            throw new RuntimeException("size differs when retrieved" +
                    " in different ways: " + size1 + " != " + size2);
        }
        System.out.println("OK");

    } catch (NoSuchFileException nsfe) {
        System.err.println("File " + BLK_FNAME + " not found." +
                " Skipping test");
    } catch (AccessDeniedException ade) {
        System.err.println("Access to " + BLK_FNAME + " is denied." +
                " Run test as root.");
    }
}
 
Example 24
Source Project: buck   Source File: StackedFileHashCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public long getSize(Path path) throws IOException {
  Optional<Pair<ProjectFileHashCache, Path>> found = lookup(path);
  if (!found.isPresent()) {
    throw new NoSuchFileException(path.toString());
  }
  return found.get().getFirst().getSize(found.get().getSecond());
}
 
Example 25
Source Project: buck   Source File: DependencyFileRuleKeyManager.java    License: Apache License 2.0 5 votes vote down vote up
public Optional<DependencyFileRuleKeyFactory.RuleKeyAndInputs> calculateDepFileRuleKey(
    Optional<ImmutableList<String>> depFile, boolean allowMissingInputs) throws IOException {

  Preconditions.checkState(useDependencyFileRuleKey());

  // Extract the dep file from the last build.  If we don't find one, abort.
  if (!depFile.isPresent()) {
    return Optional.empty();
  }

  // Build the dep-file rule key.  If any inputs are no longer on disk, this means something
  // changed and a dep-file based rule key can't be calculated.
  ImmutableList<DependencyFileEntry> inputs =
      depFile.get().stream()
          .map(ObjectMappers.fromJsonFunction(DependencyFileEntry.class))
          .collect(ImmutableList.toImmutableList());

  try (Scope ignored =
      RuleKeyCalculationEvent.scope(
          eventBus, RuleKeyCalculationEvent.Type.DEP_FILE, rule.getBuildTarget())) {
    return Optional.of(
        ruleKeyFactories
            .getDepFileRuleKeyFactory()
            .build(((SupportsDependencyFileRuleKey) rule), inputs));
  } catch (SizeLimiter.SizeLimitException ex) {
    return Optional.empty();
  } catch (Exception e) {
    // TODO(plamenko): fix exception propagation in RuleKeyBuilder
    if (allowMissingInputs && Throwables.getRootCause(e) instanceof NoSuchFileException) {
      return Optional.empty();
    }
    throw e;
  }
}
 
Example 26
Source Project: buck   Source File: StackedFileHashCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public HashCode getForArchiveMember(Path relativeArchivePath, Path memberPath)
    throws IOException {
  Optional<Pair<ProjectFileHashCache, Path>> found = lookup(relativeArchivePath);
  if (!found.isPresent()) {
    throw new NoSuchFileException(relativeArchivePath.toString());
  }
  return found.get().getFirst().getForArchiveMember(found.get().getSecond(), memberPath);
}
 
Example 27
Source Project: spring-analysis-note   Source File: FileSystemResource.java    License: MIT License 5 votes vote down vote up
/**
 * This implementation opens a NIO file stream for the underlying file.
 * @see java.io.FileInputStream
 */
@Override
public InputStream getInputStream() throws IOException {
	try {
		return Files.newInputStream(this.filePath);
	}
	catch (NoSuchFileException ex) {
		throw new FileNotFoundException(ex.getMessage());
	}
}
 
Example 28
Source Project: buck   Source File: StackedFileHashCacheTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void skipsFirstCacheAbsolutePath() throws IOException {
  Path fullPath = Paths.get("some/path");
  ProjectFilesystem filesystem =
      new FakeProjectFilesystem(CanonicalCellName.rootCell(), tmp.getRoot());
  ProjectFileHashCache innerCache =
      DefaultFileHashCache.createDefaultFileHashCache(filesystem, fileHashCacheMode);
  StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
  expectedException.expect(NoSuchFileException.class);
  cache.get(filesystem.resolve(fullPath));
}
 
Example 29
Source Project: openjdk-8   Source File: FaultyFileSystem.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkAccess(Path file, AccessMode... modes)
    throws IOException
{
    triggerEx(file, "checkAccess");
    // hack
    if (modes.length == 0) {
        if (Files.exists(unwrap(file)))
            return;
        else
            throw new NoSuchFileException(file.toString());
    }
    throw new RuntimeException("not implemented yet");
}
 
Example 30
Source Project: Bytecoder   Source File: JrtFileSystem.java    License: Apache License 2.0 5 votes vote down vote up
boolean exists(JrtPath path) throws IOException {
    try {
        checkNode(path);
    } catch (NoSuchFileException exp) {
        return false;
    }
    return true;
}