It maybe that hashcode and index is less than zero. You can add debug log to print the two vars to verify.
-- Best Regards! 肖康(Kang Xiao) 在 2014年3月6日星期四,22:51,James Xu 写道: > What is _targetTasks is empty? > > On 2014年3月6日, at 下午10:28, 李家宏 <[email protected] > (mailto:[email protected])> wrote: > > hi, all > > i'am using CustomStreamGrouping with very simple mod selection. it thrown > > IndexOutOfBoundsException. From the trace below: > > > > Caused by: java.lang.IndexOutOfBoundsException: null > > at clojure.lang.PersistentVector.arrayFor(PersistentVector.java:106) > > ~[clojure-1.4.0.jar:na] > > at clojure.lang.PersistentVector.nth(PersistentVector.java:110) > > ~[clojure-1.4.0.jar:na] > > at clojure.lang.APersistentVector.get(APersistentVector.java:167) > > ~[clojure-1.4.0.jar:na] > > at bolts.PingPongGrouping.chooseTasks(PingPongGrouping.java:37) > > ~[stormjar.jar:na] > > > > > > We locate the problem to the CustomStreamGrouping.chooseTasks() function > > which looks like: > > > > @Override > > public List<Integer> chooseTasks(int i, List<Object> values) { > > ArrayList<Integer> boltIds = new ArrayList<Integer>(); > > if (values.size() > 0) { > > int hashcode = values.get(0).hashCode(); > > int index = hashcode % _targetTasks.size(); > > boltIds.add( _targetTasks.get(index)); // here is the problem > > } else { > > boltIds.add( _targetTasks.get(0)); > > } > > return boltIds; > > } > > > > @Override > > public void prepare(WorkerTopologyContext context, GlobalStreamId > > streamId, List<Integer> targetTasks) { > > this._targetTasks = targetTasks; > > } > > > > How can it be out of bounds ? > > > > Regards > > > > -- > > ====================================================== > > Gvain > > Email: [email protected] (mailto:[email protected]) > > > > > > > > >
