google / google/jimfs

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

Open
#254 2 comments 0 reactions 0 assignees View on GitHub
P3 type=defect
Dominant language
Java
Stars
2.6k
Forks
296
Avg merge
9m
Merged PRs (30d)
7

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.