Open ngolovleva opened 6 years ago
It may be because of this: "On Linux and OS X this uses advisory locks, which have the surprising semantics that all locks associated with a given file are removed when any file descriptor for that file is closed by the process. Note that this does not actually lock the file for access. Also note that advisory locks are on a process level. This means that several isolates in the same process can obtain an exclusive lock on the same file." (A quote from https://api.dart.dev/dev/dart-io/RandomAccessFile/lock.html)
The codes below (lockSyncTest_lib.dart and lockSyncTest.dart) reproduce unexpected behaviour. The test lockSyncTest.dart fails when are executed on Linux platform, reporting:
Looks like calling "file.readAsBytesSync();" removes lock that was set with previous statement. When "file.readAsBytesSync();" is commented, test passes. Is it correct correct behavior or a bug?
Reproduced with Dart VM version: 2.0.0-dev.8.0 (Fri Nov 17 13:58:33 2017) on "linux_x64".
lockSyncTest_lib.dart file:
lockSyncTest.dart file: