diff --git a/CHANGELOG.md b/CHANGELOG.md index e43fe82c7..b1b96401b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ Bug Fixes: ([#685](https://github.com/Shopify/sarama/pull/685)). - Fix a possible tight loop in the consumer ([#693](https://github.com/Shopify/sarama/pull/693)). + - Fix possible negative partition value from the HashPartitioner + ([#709](https://github.com/Shopify/sarama/pull/709)). #### Version 1.9.0 (2016-05-16) diff --git a/partitioner.go b/partitioner.go index 892dce6db..3697ca82b 100644 --- a/partitioner.go +++ b/partitioner.go @@ -111,8 +111,7 @@ func (p *hashPartitioner) Partition(message *ProducerMessage, numPartitions int3 if err != nil { return -1, err } - hash := int32(p.hasher.Sum32()) - partition := hash % numPartitions + partition := int32(p.hasher.Sum32()) % numPartitions if partition < 0 { partition = -partition }