Skip to content

Add test for FileChannels.contentEquals.#509

Closed
smarkwal wants to merge 2 commits into
apache:masterfrom
smarkwal:filechannels-test
Closed

Add test for FileChannels.contentEquals.#509
smarkwal wants to merge 2 commits into
apache:masterfrom
smarkwal:filechannels-test

Conversation

@smarkwal

@smarkwal smarkwal commented Nov 6, 2023

Copy link
Copy Markdown

The test in this PR uses FileChannels.contentEquals to compare the content of two files. Both files have the same size of 1027 bytes. While the content of file 1 starts with "ABC", the content of file 2 starts with "XYZ". Both files then contain additional identical 1024 bytes (1024 x character "x"). The two files should be considered having different content.

If FileChannels.contentEquals is invoked with a buffer size of 1024 bytes, it will return true (content is equal) instead of the expected false (content is different).

If calling the method with a buffer size of 1023 bytes (just 1 byte less), then the method will return the correct result false.

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello @smarkwal
Thank you for the test.
Would you please add the Apache license header to the new file?

@smarkwal

smarkwal commented Nov 7, 2023

Copy link
Copy Markdown
Author

Hi @garydgregory

I have added the license header and also applied a code style that seems to be used in this project. I was not able to find an .editorconfig file or similar. But I found this CodeStyle wiki page and looked at some other source files for clues.

@smarkwal smarkwal requested a review from garydgregory November 7, 2023 19:54
asfgit pushed a commit that referenced this pull request Nov 8, 2023
- Fix FileChannels.contentEquals()
@garydgregory

Copy link
Copy Markdown
Member

Hello @smarkwal,

Thank you for your update. Please test git master or a build from the Apache Maven snapshot repository.

I did not merge this PR since it would fail the build; instead, I expanded the test, and committed a fix at the same time.

You are credited in changes.xml.

@smarkwal

smarkwal commented Nov 9, 2023

Copy link
Copy Markdown
Author

Hi @garydgregory,

Thank you very much for the quick fix and improving the test. I have been able to use 2.15.1-SNAPSHOT without problems in my project. I also did some more extensive testing and the new implementation has worked perfectly. I will close this PR.

Best,
Ste

@smarkwal smarkwal closed this Nov 9, 2023
@smarkwal smarkwal deleted the filechannels-test branch November 9, 2023 20:06
@garydgregory

Copy link
Copy Markdown
Member

👍

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.

2 participants