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

Ethan Li updated STORM-2950:
----------------------------
    Summary: ArrayIndexOutOfBoundsException in FieldsGrouper.chooseTasks 
function  (was: ArrayIndexOutOfBoundsException in TupleUtils.chooseTaskIndex 
functionFieldsGrouper.chooseTasks)

> ArrayIndexOutOfBoundsException in FieldsGrouper.chooseTasks function
> --------------------------------------------------------------------
>
>                 Key: STORM-2950
>                 URL: https://issues.apache.org/jira/browse/STORM-2950
>             Project: Apache Storm
>          Issue Type: Bug
>            Reporter: Ethan Li
>            Assignee: Ethan Li
>            Priority: Major
>
> TupleUtils.chooseTaskIndex:
> {code:java}
> public static <T> int chooseTaskIndex(List<T> keys, int numTasks) {
>     return Math.abs(listHashCode(keys)) % numTasks;
> }
> {code}
>   
> listHashCode(keys) might return Integer.MIN_VALUE (-2147483648).   
> Math.abs(-2147483648) equals to  -2147483648. 
> In this case, chooseTaskIndex might return negative numbers and it will cause 
> ArrayIndexOutOfBoundsException in FieldsGrouper.chooseTasks
> {code:java}
>  @Override
>         public List<Integer> chooseTasks(int taskId, List<Object> values) {
>             int targetTaskIndex = 
> TupleUtils.chooseTaskIndex(outFields.select(groupFields, values), numTasks);
>             return targetTasks.get(targetTaskIndex);
>         }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to