-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
Avoid creating FileInputStream and FileOutputStream for obtaining FileChannel #8078
Labels
Milestone
Comments
Same goes for BufferedReader instances - same finalize problem. It's used in DNS and some other modules. |
normanmaurer
added a commit
that referenced
this issue
Jul 9, 2018
…eChannel Motivation: If all we need is the FileChannel we should better use RandomAccessFile as FileInputStream and FileOutputStream use a finalizer. Modifications: Replace FileInputStream and FileOutputStream with RandomAccessFile when possible. Result: Fixes #8078.
normanmaurer
added a commit
that referenced
this issue
Jul 9, 2018
…eChannel Motivation: If all we need is the FileChannel we should better use RandomAccessFile as FileInputStream and FileOutputStream use a finalizer. Modifications: Replace FileInputStream and FileOutputStream with RandomAccessFile when possible. Result: Fixes #8078.
normanmaurer
added a commit
that referenced
this issue
Aug 16, 2019
…eChannel Motivation: If all we need is the FileChannel we should better use RandomAccessFile as FileInputStream and FileOutputStream use a finalizer. Modifications: Replace FileInputStream and FileOutputStream with RandomAccessFile when possible. Result: Fixes #8078.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are multiple places in the production code of the project, e. g. in
ChunkedNioFile
, whereFileInputStream
orFileOutputStream
are created solely to obtain aFileChannel
from them. Until Netty projects bumps the compatibility level to Java 7 (whereFileChannel.open()
methods were added), it's better to obtain a FileChannel by means of creating aRandomAccessFile
, because the latter doesn't overrideObject.finalize()
. Also, I would extract those pieces of code into a utility methods likeopenChannelForRead(File)
andopenChannelForWrite(File)
.The text was updated successfully, but these errors were encountered: