[ 
https://issues.apache.org/jira/browse/HADOOP-8853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16506470#comment-16506470
 ] 

Joseph Smith commented on HADOOP-8853:
--------------------------------------

Looks like a duplicate to HADOOP-11901

> BytesWritable setsize unchecked
> -------------------------------
>
>                 Key: HADOOP-8853
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8853
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: io
>    Affects Versions: 2.0.1-alpha
>            Reporter: Sven Meys
>            Priority: Major
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When setting an array of length 1183230720 (in my case), the method will 
> return a negative array index exception.
> Cause is the following method.
> public void setSize(int size) {
>     if (size > getCapacity()) {
>       setCapacity(size * 3 / 2);
>     }
>     this.size = size;
>   }
> size * 3 has precedence which means that for any value greater than 
> 715.827.882 (682,6 MB), the result will overflow and become negative. Thus 
> this method is unsafe.
> It would be nice to have this hidden feature documented or have a failsafe in 
> place.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to