[9] RFC on 8073061: Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable
Alan Bateman
Alan.Bateman at oracle.com
Wed Feb 18 06:56:25 UTC 2015
On 18/02/2015 00:56, Brian Burkhalter wrote:
> Please comment at your convenience.
>
> Issue: https://bugs.openjdk.java.net/browse/JDK-8073061
> Patch: http://cr.openjdk.java.net/~bpb/8073061/webrev.00/
>
> Note that this is for now a RFC as opposed to a RFR. The copyright date of the affected file has not been updated, and there is no new test nor modification of an existing test specific to this change. The change does however pass the test provided in the issue description, and a JPRT job run on the usual suspect platforms with these options -testset core -onlytests '.*jdk_nio.*’ succeeds.
>
> I am not sure that this is the correct approach to take here and would prefer to hear some comment(s) before formalizing an RFR.
>
> The rationale for the change is to avoid deleting the target of the operation (copy(), move()) until the last possible opportunity. This is so that if something fails unexpectedly, the target of the operation will not be deleted in addition to the operation itself failing.
>
copy & move are complicated as it requires dealing with many different
file types, sym links, etc. For the regular file case and when
overwriting an existing file then it needs to truncate the existing file
rather than deleting it (that is what this bug is about). I'm busy with
other things at the moment but I will try to get time to outline a patch
when get time (assuming you don't get there first).
-Alan
More information about the nio-dev
mailing list