Skip to content

HDDS-14370. RandomAccessFileChannel to implement Closeable#9905

Open
rich7420 wants to merge 6 commits intoapache:masterfrom
rich7420:HDDS-14370
Open

HDDS-14370. RandomAccessFileChannel to implement Closeable#9905
rich7420 wants to merge 6 commits intoapache:masterfrom
rich7420:HDDS-14370

Conversation

@rich7420
Copy link
Contributor

What changes were proposed in this pull request?

The class already had a close() method but didn't implement Closeable, which could lead to resource leaks if developers miss calling close().

What is the link to the Apache JIRA

HDDS-14370

How was this patch tested?

https://github.com/rich7420/ozone/actions/runs/22942351747

reopen

#9628

@adoroszlai adoroszlai requested a review from jojochuang March 11, 2026 14:48
@adoroszlai
Copy link
Contributor

@Gargi-jais11 please take a look

Copy link

@yandrey321 yandrey321 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

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

Thanks @rich7420 for updating the patch. LGTM!

@rich7420
Copy link
Contributor Author

Thanks so much @adoroszlai , @yandrey321 and @Gargi-jais11

* {@link FileChannel#close()} is final (inherited), so we implement a minimal {@link FileChannel}
* and throw from {@link #implCloseChannel()} to simulate close failure.
*/
private static final class FailingCloseFileChannel extends FileChannel {
Copy link
Member

Choose a reason for hiding this comment

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

could we find other to verify the close behaviour? there are so much code that are unused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants