[ https://issues.apache.org/jira/browse/GEODE-43?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dan Smith resolved GEODE-43. ---------------------------- Resolution: Fixed This issue was resolved with the merge of feature/GEODE-8 to develop [ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=b205339 ] > 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 > > 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)