[VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent#93
Merged
garydgregory merged 2 commits intoapache:masterfrom Sep 6, 2020
Conversation
garydgregory
reviewed
Aug 4, 2020
| public int read() throws IOException { | ||
| try { | ||
| return raf.readByte(); | ||
| return raf.readByte() & 0xFF; |
Member
There was a problem hiding this comment.
Let's avoid repeated use of a magic number. Please refactor into a constant that's reused in the code and tests. Same for -1.
Member
Author
There was a problem hiding this comment.
Sure.
Seems we need a place to store the constant 0xFF. IMO we should have a class to store constants like 0xFF, which seems is not presented in VFS. What about adding a VFSConstants class in org.apache.commons.vfs2.util?
Member
There was a problem hiding this comment.
For now I would just add it as a constant in RamFileRandomAccessContent. The only other place I see it used, is once in an unrelated sandbox class.
8e96ab3 to
25d74be
Compare
… reading 0xFF Fix and add a test.
25d74be to
b4a84c1
Compare
Fix and add a test. This problem is similar to VFS-624 Replace all 0xFF to constant BYTE_VALUE_MASK
b4a84c1 to
fba2243
Compare
asfgit
pushed a commit
that referenced
this pull request
Sep 6, 2020
and RamFileRandomAccessContent #93.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As VFS-624 described, the
readof the inner class inLocalFileRandomAccessContentwould return-1if it's reading a0xFFin file.This is a fix for it.
And the same problem also exists in
RamFileRandomAccessContentand the fix is also included in this PR.