[ 
https://issues.apache.org/jira/browse/KAFKA-1988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14339924#comment-14339924
 ] 

Tong Li commented on KAFKA-1988:
--------------------------------

Jun Rao,
        Thanks for taking time reviewing the patch. Would like to confirm here 
is what you suggested to do:

        1. Utils.abs will be renamed to Utils.toPositive
        2. Make changes in these methods of class DefaultPartitioner and 
ByteArrayPartitioner so that toPositive gets called in partition method.

                def partition(key: Any, numPartitions: Int): Int = {
                        Utils.abs(key.hashCode) % numPartitions
                }


        I can certainly make the above changes.  however method abs gets used 
many other places and making the case worse is that there are two abs methods 
both in core and clients. I found this problem when I was in an effort of 
addressing issue 1926. For now, what if I keep that method in clients, remove 
the one in core Utils module and making changes to all other modules where abs 
method gets called so that all use of abs method will point to the clients 
Utils.abs instead of two locations?

The patch set reflects the above thoughts is here 
https://reviews.apache.org/r/31533/diff/

> org.apache.kafka.common.utils.Utils.abs method returns wrong value for 
> negative numbers.
> ----------------------------------------------------------------------------------------
>
>                 Key: KAFKA-1988
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1988
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 0.8.2.0
>            Reporter: Tong Li
>            Assignee: Tong Li
>            Priority: Blocker
>             Fix For: 0.8.2.1
>
>         Attachments: KAFKA-1988.patch, KAFKA-1988.patch
>
>
> org.apache.kafka.common.utils.Utils.abs method returns wrong value for 
> negative numbers. The method only returns intended value for positive 
> numbers. All negative numbers except the Integer.Min_Value will be returned 
> an unsigned integer.



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

Reply via email to