Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6
-
Fix Version/s: JRuby 1.6.1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Solaris 10
-
Number of attachments :
Description
In JRUBY-1214 the behavior of File.flock was changed to silently convert LOCK_EX locks on files opened in read mode into LOCK_SH locks. This was because some operating systems allow setting LOCK_EX on files opened for read only. However, this is not specified in POSIX. In fact, on Solaris, when trying to get an exclusive lock on a file opened only for read, the OS will return EBADF. So this isn't really a MRI vs JVM issue, but an OS issue. Any code that depends on this behavior in MRI is not portable.
All of that aside, this violates the principle of least surprise. No one asking for an exclusive lock is going to be happy when their lock is silently converted to a shared lock, and this could very easily lead to silent data corruption.