[
https://issues.apache.org/jira/browse/VFS-624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Goitia Amigo updated VFS-624:
-----------------------------------
Description:
The LocalFileRandomAccessContent InputStream used for reading a byte as an int
is calling the RandomAccessFile method readByte(byte), so it returns -1 in case
of EOFException, but also in case of reading 0xFF in a file.
This also violates the expected behaviour of the read() method of the
InputStream as can return negative values as result of the casting, while
should only return an int value beetween 0 and 255, or -1 in case of eof.
This problem is also inherited by the default read(byte[]) and read(byte[], int
off, int length).
The solution is to change the implementation to:
raf.read();
Pull request: https://github.com/apache/commons-vfs/pull/17
was:
The LocalFileRandomAccessContent InputStream used for reading a byte as an int
is calling the RandomAccessFile method readByte(byte), so it returns -1 in case
of EOFException, but also in case of reading 0xFF in a file.
This also violates the expected behaviour of the read() method of the
InputStream as can return negative values as result of the casting, while
should only return an int value beetween 0 and 255, or -1 in case of eof.
This problem is also inherited by the default read(byte[]) and read(byte[], int
off, int length).
The solution is to change the implementation to:
raf.read();
> LocalFileRandomAccessContent returning wrong value when reading 0xFF
> --------------------------------------------------------------------
>
> Key: VFS-624
> URL: https://issues.apache.org/jira/browse/VFS-624
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0, 2.1
> Reporter: David Goitia Amigo
> Priority: Critical
> Labels: easyfix
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> The LocalFileRandomAccessContent InputStream used for reading a byte as an
> int is calling the RandomAccessFile method readByte(byte), so it returns -1
> in case of EOFException, but also in case of reading 0xFF in a file.
> This also violates the expected behaviour of the read() method of the
> InputStream as can return negative values as result of the casting, while
> should only return an int value beetween 0 and 255, or -1 in case of eof.
> This problem is also inherited by the default read(byte[]) and read(byte[],
> int off, int length).
> The solution is to change the implementation to:
> raf.read();
> Pull request: https://github.com/apache/commons-vfs/pull/17
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)