You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/06/15 13:01:52 UTC

[GitHub] [commons-vfs] PeterAlfredLee opened a new pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

PeterAlfredLee opened a new pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93


   As [VFS-624](https://issues.apache.org/jira/projects/VFS/issues/VFS-624?filter=allopenissues) described, the `read`of the inner class in `LocalFileRandomAccessContent` would return `-1` if it's reading a `0xFF` in file.
   This is a fix for it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-vfs] garydgregory merged pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

Posted by GitBox <gi...@apache.org>.
garydgregory merged pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-vfs] garydgregory commented on a change in pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93#discussion_r465702259



##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
##########
@@ -45,7 +45,7 @@
                 @Override
                 public int read() throws IOException {
                     try {
-                        return raf.readByte();
+                        return raf.readByte() & 0xFF;

Review 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.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-vfs] garydgregory commented on a change in pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93#discussion_r465055550



##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
##########
@@ -45,7 +45,7 @@
                 @Override
                 public int read() throws IOException {
                     try {
-                        return raf.readByte();
+                        return raf.readByte() & 0xFF;

Review comment:
       Let's avoid repeated use of a magic number. Please refactor into a constant that reused in the code and tests. Same for -1.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-vfs] PeterAlfredLee commented on a change in pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

Posted by GitBox <gi...@apache.org>.
PeterAlfredLee commented on a change in pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93#discussion_r465428972



##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
##########
@@ -45,7 +45,7 @@
                 @Override
                 public int read() throws IOException {
                     try {
-                        return raf.readByte();
+                        return raf.readByte() & 0xFF;

Review 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`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-vfs] garydgregory commented on a change in pull request #93: [VFS-624] Fix for read() in constructors of LocalFileRandomAccessContent and RamFileRandomAccessContent

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #93:
URL: https://github.com/apache/commons-vfs/pull/93#discussion_r465055550



##########
File path: commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
##########
@@ -45,7 +45,7 @@
                 @Override
                 public int read() throws IOException {
                     try {
-                        return raf.readByte();
+                        return raf.readByte() & 0xFF;

Review 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.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org