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

Sven Meys updated HADOOP-8853:
------------------------------

    Description: 
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.


  was:
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) this method is unsafe.

It would be nice to have this hidden feature documented or have a failsafe in 
place.


    
> 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
>   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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to