Skip to content
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

Possible instances of Channel opened but not safely closed #12129

Closed
timveil opened this issue Dec 8, 2023 · 0 comments · Fixed by #12130
Closed

Possible instances of Channel opened but not safely closed #12129

timveil opened this issue Dec 8, 2023 · 0 comments · Fixed by #12130
Labels

Comments

@timveil
Copy link
Collaborator

timveil commented Dec 8, 2023

found three possible instances of a Channel being opened but not properly closed. this could lead to resource leaks.

for example, this...

try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r")) {
  ...
  randomAccessFile.getChannel().read(duplicate, srcOffset);
}

should really be this...

try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
    FileChannel channel = randomAccessFile.getChannel()) {
  ...
  channel.read(duplicate, srcOffset);
}
timveil added a commit to timveil-startree/pinot that referenced this issue Dec 8, 2023
…ache#12129

This commit modifies several classes to use a try-with-resource block for file operations, conforming with best practices for Java resource management. Previously, file resources such as RandomAccessFile and FileOutputStream were not included in a try-with-resource statement, which could lead to resource leaks if exceptions occurred. The changes ensure these resources are properly closed after usage.
@walterddr walterddr added the bug label Dec 14, 2023
Jackie-Jiang pushed a commit that referenced this issue Dec 14, 2023
…2129 (#12130)

This commit modifies several classes to use a try-with-resource block for file operations, conforming with best practices for Java resource management. Previously, file resources such as RandomAccessFile and FileOutputStream were not included in a try-with-resource statement, which could lead to resource leaks if exceptions occurred. The changes ensure these resources are properly closed after usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants