Skip to content

Files.newOutputStream throws if file is a symlink to a non-existing target. #254

Description

@oldergod

For simplicity, here is what I do in bash:

$ ls symlink-target
> ls: symlink-target: No such file or directory
$ ln -s symlink-target symlink-source
$ echo hello > symlink-source
$ cat symlink-target
> hello

Jimfs would throw the following (version: 1.2)

java.nio.file.FileSystemException: symlink-source: not a regular file
	at com.google.common.jimfs.FileSystemView.getOrCreateRegularFileWithWriteLock(FileSystemView.java:336)
	at com.google.common.jimfs.FileSystemView.getOrCreateRegularFile(FileSystemView.java:298)
	at com.google.common.jimfs.JimfsFileSystemProvider.newOutputStream(JimfsFileSystemProvider.java:201)
	at java.base/java.nio.file.Files.newOutputStream(Files.java:228)

The code would work fine if I were to use Filesystems.getDefault(), and as show at the top, this would also work in the CLI.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3type=defectBug, not working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions