You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Anthony Baker (JIRA)" <ji...@apache.org> on 2016/01/15 07:14:54 UTC

[jira] [Closed] (GEODE-43) Integer overflow in PartitionedRegionLoadModel

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

Anthony Baker closed GEODE-43.
------------------------------

> Integer overflow in PartitionedRegionLoadModel
> ----------------------------------------------
>
>                 Key: GEODE-43
>                 URL: https://issues.apache.org/jira/browse/GEODE-43
>             Project: Geode
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.0.0-incubating
>            Reporter: Dan Smith
>            Assignee: Dan Smith
>             Fix For: 1.0.0-incubating.M1
>
>
> PartitionRegionLoadModel.getAverageLoad() is casting a float to an integer and potentially overflowing. totalLoad here is size of a region in bytes, this code easily be bigger than Integer.MaxValue.
> {code}
> private float getAverageLoad() {
>     if(this.averageLoad == -1) {
>       float totalWeight = 0;
>       int totalLoad = 0;
>       for(Member member : this.members.values()) {
>         totalLoad += member.getTotalLoad();
>         totalWeight += member.getWeight();
>       }
>       
>       this.averageLoad = totalLoad / totalWeight;
>     }
>     
>     return this.averageLoad;
>   }
> {code}
> member.getTotalLoad() returns a float.
> Interestingly, if this expression is written as below, the compiler will complain:
> {code}
> totalLoad = totalLoad + member.getTotalLoad()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)