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

[BugFix] Fix to prevent resource leaks in 3 classes #4449

Merged
merged 2 commits into from
Jul 6, 2024

Conversation

dk2k
Copy link
Contributor

@dk2k dk2k commented Jun 25, 2024

Implemented try-with-resources for instances of Autocloseable

@@ -180,23 +180,24 @@ private synchronized BufferedLogChannel allocateNewLog(File dirForNextEntryLog,
} while (testLogFile == null);

File newLogFile = new File(dirForNextEntryLog, logFileName);
FileChannel channel = new RandomAccessFile(newLogFile, "rw").getChannel();
try (FileChannel channel = new RandomAccessFile(newLogFile, "rw").getChannel()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a good idea to close the channel here? it is used by the logChannel that is being returned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted changes for this file

@dk2k dk2k requested a review from dlg99 July 1, 2024 18:19
Copy link
Member

@shoothzj shoothzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we have been leaked some resources for long, really? Need more eyes. @nicoloboschi @hangc0276 @nodece

@nodece
Copy link
Member

nodece commented Jul 4, 2024

It seems we have been leaked some resources for long, really? Need more eyes. @nicoloboschi @hangc0276 @nodece

Looks like it. We should take care of it.

Copy link
Member

@shoothzj shoothzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think we need to change the commit and PR title. It's a fix of leak

@dk2k dk2k changed the title [Improvement] Implemented try-with-resources for instances of Autoclo… [BugFix] Fix to prevent resource leaks in 3 classes Jul 5, 2024
@dk2k dk2k requested a review from shoothzj July 5, 2024 18:56
@shoothzj shoothzj merged commit a164bca into apache:master Jul 6, 2024
25 checks passed
@shoothzj
Copy link
Member

shoothzj commented Jul 6, 2024

Thanks for your contribution!

Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants