Skip to content

Conversation

@katzyn
Copy link
Contributor

@katzyn katzyn commented May 3, 2022

  1. Our usual workaround for toRealPath() is used for newDirectoryStream() too. Closes FilePathDisk.newDirectoryStream() may fail on remote drive on Windows due to AccessDeniedException in Path.toRealPath() #3486.
  2. FileLister.getDatabaseFiles() doesn't call toRealPath() by itself anymore. It was needed only because FilePath.newDirectoryStream() returns real names, but toRealPath() was called with a fake name. If such file or directory exists with different case of characters on case-insensitive file system a wrong prefix for test was generated. With the new implementation FilePath.getName() is used for filtration. Closes org.h2.tools.DeleteDbFiles won't delete files under certain circumstances #3493.

}

@Override
public List<FilePath> newDirectoryStream() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MixedMutabilityReturnType: This method returns both mutable and immutable collections or maps from different paths. This may be confusing for users of the method.

Suggested change
public List<FilePath> newDirectoryStream() {
return ImmutableList.copyOf(files.collect(ArrayList::new, (t, u) -> t.add(getPath(u.toString())), ArrayList::addAll));

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonatype-lift ignore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@Override
public List<FilePath> newDirectoryStream() {
try (Stream<Path> files = Files.list(Paths.get(name).toRealPath())) {
try (Stream<Path> files = Files.list(toRealPath(Paths.get(name)))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonatype-lift ignore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@Override
public FilePathDisk toRealPath() {
Path path = Paths.get(name);
return getPath(toRealPath(Paths.get(name)).toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonatype-lift ignore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recorded this as ignored for this pull request. If you change your mind, just comment @sonatype-lift unignore.

@katzyn katzyn merged commit a4bc177 into h2database:master May 3, 2022
@katzyn katzyn deleted the nio2 branch May 3, 2022 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant