Hi Mandy,

On 01/20/2017 05:55 PM, Mandy Chung wrote:
Webrev:
    http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8173096/webrev.00/index.html

A recent change in jmod tool [1] creates the JMOD file with no group
and other readable permission as that’s the default permission when
creating a temporary file with Files::createTempFile.  This fixes
the permission issue by creating the JMOD file in a temporary directory.

Mandy
[1] https://bugs.openjdk.java.net/browse/JDK-8173096

I guess the JmodTask is creating a temp file because it wants the file to not be observed by other processes while it is being written to, right? At the end when the tempTarget is fully written, it is renamed to its intended name with:

Files.move(tempTarget, target);


...but that operation will not be atomic since you didn't pass ATOMIC_MOVE to the CopyOption... options. Even if you did, the atomic move will succeed only when both tempTarget and target point to the same filesystem. Since you are creating tempTarget in default temporary files location (/tmp on UNIXes) this might not be the case (depending on where the real target is located).

So why don't you simply append a .tmp suffix to the intended target file name when opening the JmodOutputStream. This would ensure the file location will be on the same filesystem as the final target name as it will be created in the same directory. Module path scanning should skip files with .tmp extension then.

Regards, Peter


Reply via email to