[jira] [Updated] (HDDS-2784) Read to ByteBuffer uses wrong offset

2020-01-06 Thread Shashikant Banerjee (Jira)


 [ 
https://issues.apache.org/jira/browse/HDDS-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Shashikant Banerjee updated HDDS-2784:
--
Fix Version/s: 0.5.0
   Resolution: Fixed
   Status: Resolved  (was: Patch Available)

Thanks [~adoroszlai] for working on this. I have committed this.

> Read to ByteBuffer uses wrong offset
> 
>
> Key: HDDS-2784
> URL: https://issues.apache.org/jira/browse/HDDS-2784
> Project: Hadoop Distributed Data Store
>  Issue Type: Bug
>  Components: Ozone Filesystem
>Reporter: Attila Doroszlai
>Assignee: Attila Doroszlai
>Priority: Major
>  Labels: pull-request-available
> Fix For: 0.5.0
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{OzoneFSInputStream#read(ByteBuffer)}} uses the target buffer's position for 
> offsetting into the temporary array:
> {code:title=https://github.com/apache/hadoop-ozone/blob/b834fa48afef4ee4c73577c7af564e1e97cb9d5b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java#L90-L97}
>   public int read(ByteBuffer buf) throws IOException {
> int bufInitPos = buf.position();
> int readLen = Math.min(buf.remaining(), inputStream.available());
> byte[] readData = new byte[readLen];
> int bytesRead = inputStream.read(readData, bufInitPos, readLen);
> buf.put(readData);
> {code}
> Given a buffer with capacity=10 and position=8, this results in the following:
>  * {{readLen}} = 2 => {{readData.length}} = 2
>  * {{bufInitPos}} = 8
> So {{inputStream}} reads 2 bytes and writes it into {{readData}} starting at 
> offset 8, which results in an {{IndexOutOfBoundsException}}.
> offset should always be 0, since the temporary array is sized exactly for the 
> length to read, and it has no extra data at the start.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org



[jira] [Updated] (HDDS-2784) Read to ByteBuffer uses wrong offset

2020-01-02 Thread Attila Doroszlai (Jira)


 [ 
https://issues.apache.org/jira/browse/HDDS-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Attila Doroszlai updated HDDS-2784:
---
Status: Patch Available  (was: In Progress)

> Read to ByteBuffer uses wrong offset
> 
>
> Key: HDDS-2784
> URL: https://issues.apache.org/jira/browse/HDDS-2784
> Project: Hadoop Distributed Data Store
>  Issue Type: Bug
>  Components: Ozone Filesystem
>Reporter: Attila Doroszlai
>Assignee: Attila Doroszlai
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> {{OzoneFSInputStream#read(ByteBuffer)}} uses the target buffer's position for 
> offsetting into the temporary array:
> {code:title=https://github.com/apache/hadoop-ozone/blob/b834fa48afef4ee4c73577c7af564e1e97cb9d5b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java#L90-L97}
>   public int read(ByteBuffer buf) throws IOException {
> int bufInitPos = buf.position();
> int readLen = Math.min(buf.remaining(), inputStream.available());
> byte[] readData = new byte[readLen];
> int bytesRead = inputStream.read(readData, bufInitPos, readLen);
> buf.put(readData);
> {code}
> Given a buffer with capacity=10 and position=8, this results in the following:
>  * {{readLen}} = 2 => {{readData.length}} = 2
>  * {{bufInitPos}} = 8
> So {{inputStream}} reads 2 bytes and writes it into {{readData}} starting at 
> offset 8, which results in an {{IndexOutOfBoundsException}}.
> offset should always be 0, since the temporary array is sized exactly for the 
> length to read, and it has no extra data at the start.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org



[jira] [Updated] (HDDS-2784) Read to ByteBuffer uses wrong offset

2020-01-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDDS-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated HDDS-2784:
-
Labels: pull-request-available  (was: )

> Read to ByteBuffer uses wrong offset
> 
>
> Key: HDDS-2784
> URL: https://issues.apache.org/jira/browse/HDDS-2784
> Project: Hadoop Distributed Data Store
>  Issue Type: Bug
>  Components: Ozone Filesystem
>Reporter: Attila Doroszlai
>Assignee: Attila Doroszlai
>Priority: Major
>  Labels: pull-request-available
>
> {{OzoneFSInputStream#read(ByteBuffer)}} uses the target buffer's position for 
> offsetting into the temporary array:
> {code:title=https://github.com/apache/hadoop-ozone/blob/b834fa48afef4ee4c73577c7af564e1e97cb9d5b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java#L90-L97}
>   public int read(ByteBuffer buf) throws IOException {
> int bufInitPos = buf.position();
> int readLen = Math.min(buf.remaining(), inputStream.available());
> byte[] readData = new byte[readLen];
> int bytesRead = inputStream.read(readData, bufInitPos, readLen);
> buf.put(readData);
> {code}
> Given a buffer with capacity=10 and position=8, this results in the following:
>  * {{readLen}} = 2 => {{readData.length}} = 2
>  * {{bufInitPos}} = 8
> So {{inputStream}} reads 2 bytes and writes it into {{readData}} starting at 
> offset 8, which results in an {{IndexOutOfBoundsException}}.
> offset should always be 0, since the temporary array is sized exactly for the 
> length to read, and it has no extra data at the start.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org