ManagedFile is platform dependent
After we made a quick fix of the FileLockTest in #24606 (original test just printed errors to the stdout, but did not fail), it made visible problem in ManagedFile class - it is platform dependent and the file locking mechanism generally doesn't work.
FileLockTest passes on Linux systems, now it passes also on Windows, but we had to duplicate the test so now it has different results on Windows and Linux. And now @arjantijms found that there's another failure on Mac.
FileLockTest.lockAndRenameTest:364 File renaming blocked ==> expected: <true> but was: <false>
~/which_java.sh
/dev/stdin: Mach-O 64-bit executable arm64
uname -a
Darwin Arjans-MacBook-Pro.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Then we should to this:
- Investigate if we really need the ManagedFile class and classes around that
- Investigate if it can be fixed so the mechanism would work on all operating systems.
- Make the decision and do the work required.
See also https://github.com/eclipse-ee4j/glassfish/pull/24623 , where we tried to avoid another test failure on one operating system.
Just for completeness, this is a javadoc of the File.rename method:
Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.
I have take a look at it. It seems like you guys want to use FileLock to implement a system level read-write lock. I saw it used in DomainXmlPersistence, but FileLock is system dependent. maybe we can use Unix Domain Socket to implement it? I checked it implemented in Linux, Windows and MacOS, but it requires Java 16 or above.
This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment
ManagedFile was deleted in #25205