You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* Convert the flags in this object to a set of flags appropriate for the
* OpenFile structure and logic therein.
*
* @return an int of flags appropriate for OpenFile
*/
On the other hand the ModeFlags(int) constructor just uses the integer passed in
for the internal flags value. Those flags eare interpreted according to OpenFlags
constants. Thos are not (necessarily) compatible with flags according to OpenFile
This causes wrong open modes for the resulting file.
This bug is subtle as some openmodes may end up compatible.
E.g. for most platforms OpenFlags modes are (interesting part)
RDONLY 0
WRONLY 1
RDWR 2
While ÒpenFiles` has
public static final int READABLE = 0x00000001;
public static final int WRITABLE = 0x00000002;
public static final int READWRITE = READABLE | WRITABLE;
In case of RDWR getOpenFileFlags() returns 2 (WRITABLE).
Fed into the constructor this ends up as being RDWRagain.
If you are not going to read the file (despite setting RDWR the effect will get by unnoticed.
since 1.7 is EOL and 9K has a redone IO sub-system I'd close this one.
if anyone feels like the proposal is worth doing - please submit a PR it will likely get accepted.
Environment
JRuby 1.7x (bundled with sonarqube)
Detected with jruby-complete-1.7.9.jar
Sill detectable with jruby-complete-1.7.25.jar
Platform: NetBSD 7.0_STABLE
Expected Behavior
Open modes stay constant.
Actual Behavior
Open modes get mangled
Analysis
(code shown is from jruby 1.7.25)
TempfileClallback.call()
method initializes ioOptions :In may case no further modifications of this value occurs.
This value is passed some lines down:
This method looks as follows:
However,
sysopeninternal19
(from RubyFile) is creating a new ModeFlags instance from the second parameter (namedoflags
) there.Now, javadoc for getOpenFileFlags() states:
On the other hand the
ModeFlags(int)
constructor just uses the integer passed infor the internal flags value. Those flags eare interpreted according to
OpenFlags
constants. Thos are not (necessarily) compatible with flags according to
OpenFile
This causes wrong open modes for the resulting file.
This bug is subtle as some openmodes may end up compatible.
E.g. for most platforms OpenFlags modes are (interesting part)
While ÒpenFiles` has
In case of RDWR
getOpenFileFlags()
returns2
(WRITABLE
).Fed into the constructor this ends up as being
RDWR
again.If you are not going to read the file (despite setting
RDWR
the effect will get by unnoticed.Proposed Fix
change
to
The text was updated successfully, but these errors were encountered: