On Fri, 24 Sep 2021 12:57:02 GMT, Pavel Rappo <[email protected]> wrote:

>> Jonathan Gibbons has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Address review comments;
>>   Move `JavadocTester.copyDir` to `ToolBox`; use FileVisitor code
>
> test/langtools/tools/lib/toolbox/ToolBox.java line 283:
> 
>> 281:                                 if (!Files.isDirectory(toSubdir))
>> 282:                                     throw e;
>> 283:                             }
> 
> If we do not expect the target directory to ever exist, we should remove this 
> try-catch. This would make us fail fast, rather than add something to the 
> existing file tree silently. Also, this situation could only happen in the 
> first call to this method, right?
> Suggestion:
> 
>                             Files.copy(fromSubdir, toSubdir);

Let me clarify my sloppy writing.

> this situation could only happen in the first call to this method

Here I wanted to convey that if FileAlreadyExistsException is NOT thrown during 
the first call to preVisitDirectory, then this exception will NOT be thrown 
during subsequent calls to that same method, assuming we're exclusively 
modifying this tree. Indeed, if we are copying directory, then the first call 
to the visitor will be to this very method. If the target directory does not 
already exist, then neither do any subdirectories.

This FileVisitor example hints why there are no convenience methods for file 
tree copying: there are many ways to copy a file tree.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5644

Reply via email to