New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3329: javalib MappedByteBufferImpl no longer calls FileChannel truncate method #3345
Fix #3329: javalib MappedByteBufferImpl no longer calls FileChannel truncate method #3345
Conversation
val channel = FileChannel.open( | ||
f, | ||
StandardOpenOption.READ, | ||
StandardOpenOption.WRITE | ||
) | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use Using
to manage the resource here rather than try
, finally
. https://www.scala-lang.org/api/2.13.6/scala/util/Using$.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eric,
Thank you for the suggestion. This code needs to also run on Scala 2.12.n.
I believe that Using
is not available for that Scala version. `Tis a pity,
the Using
idiom is much closer to the Java try-with-resources
idiom.
Did I miss something in Scala 2.12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is added in Scala Collection Compat but I don't think we want to add that. - https://github.com/scala/scala-collection-compat/tree/main/compat/src/main/scala-2.12/scala/util :-(
…ileChannel truncate method (scala-native#3345) * Fix scala-native#3329: javalib MappedByteBufferImpl no longer calls truncate method * Change Exception message to match a JVM (cherry picked from commit 4687be0)
Fix #3329
Credit:
Aly on Scala Native Discourse gave invaluable information on how Windows extends files.
Any defects from misinterpretation of that information fall on this Author.
Changes
javalib
MappedByteBufferImpl
no longer callsFileChannel#truncate
to extend files.The latter method is defined as never extending a file, so the former method calling
the latter was a defect.
This is primarily an internal re-organization which prepares the ground for correcting the more
visible and impactful Issue #3330.
A keen user may detect three user visible changes.
IllegalArgumentException
was changed to match (a, not every) JVM.