[
https://issues.apache.org/jira/browse/GEODE-43?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anthony Baker updated GEODE-43:
-------------------------------
Fix Version/s: 1.0.0-alpha1
> 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-alpha1
>
>
> 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)