Buggy code:
public class Topology { protected static final Logger logger = LoggerFactory . getLogger ( Topology . class ) ; public String name ; private int maxMissing = Integer . MAX_VALUE ; public List < BlockingQueue < EmitItem > > messageQueueList ; public Spout [ ] spoutGroup ; public ExecutorService spoutService ; public List < Bolt [ ] > boltGroupList ; public List < ExecutorService > boltServiceList ; public long waitTime = 1000L ; public AtomicBoolean running = new AtomicBoolean ( false ) ; private DBHandler dbHandler ; public Topology ( String name , DBHandler db ) { } public Topology ( String name ) { } public Topology ( ) { } public void init ( ) { } public Topology setSpout ( Spout spout , int spoutNum ) { } public Topology setBolt ( Bolt bolt , int boltNum ) { } public void prepare ( ) throws Exception { } public void reload ( ) { try { String sLastSucc = getDbHandler ( ) . getStringValue ( ( ( name ) + ":lastsucc" ) ) ; long lastSucc = ( sLastSucc == null ) ? - 1 : Long . valueOf ( sLastSucc ) ; Topology . logger . info ( ( ( "Last<seq2seq4repair_space>success<seq2seq4repair_space>xid<seq2seq4repair_space>is<seq2seq4repair_space>" + lastSucc ) + ",<seq2seq4repair_space>now<seq2seq4repair_space>ready<seq2seq4repair_space>to<seq2seq4repair_space>load<seq2seq4repair_space>un-finish<seq2seq4repair_space>task." ) ) ; <START_BUG> long reloadSize = XidManager . getCurrent ( dbHandler , name ) ; <END_BUG> if ( reloadSize > 0 ) { for ( long i = lastSucc + 1 ; i < reloadSize ; i ++ ) { String sPackageId = getDbHandler ( ) . getStringValue ( ( ( ( name ) + ":" ) + i ) ) ; int packageId = ( sPackageId == null ) ? - 1 : Integer . valueOf ( sPackageId ) ; Topology . logger . info ( ( ( ( ( "Reload<seq2seq4repair_space>the<seq2seq4repair_space>Xid<seq2seq4repair_space>" + i ) + "<seq2seq4repair_space>package<seq2seq4repair_space>0<seq2seq4repair_space>to<seq2seq4repair_space>" ) + packageId ) + "." ) ) ; List < Serializable > l = new ArrayList < Serializable > ( ) ; for ( int j = 0 ; j <= packageId ; j ++ ) { Serializable s = Util . ByteToObject ( getDbHandler ( ) . getByteWiseValue ( ( ( ( ( ( name ) + ":" ) + i ) + ":" ) + j ) ) ) ; if ( s != null ) l . add ( s ) ; } if ( ( l . size ( ) ) > 0 ) messageQueueList . get ( 0 ) . put ( new EmitItem ( i , l . toArray ( new Serializable [ l . size ( ) ] ) ) ) ; } } Topology . logger . info ( "Reload<seq2seq4repair_space>un-finish<seq2seq4repair_space>task<seq2seq4repair_space>ok." ) ; } catch ( Exception e ) { Topology . logger . error ( ( ( "Topology<seq2seq4repair_space>" + ( name ) ) + "<seq2seq4repair_space>do<seq2seq4repair_space>last<seq2seq4repair_space>task<seq2seq4repair_space>failed." ) , e ) ; e . printStackTrace ( ) ; } } public void start ( ) { } public boolean spoutFinish ( ) { } public boolean boltFinish ( int index ) { } public int getSpoutProcessMessageNumber ( ) { } public int getBoltProcessMessageNumber ( int index ) { } public void showStats ( ) { } public void shutdown ( ) { } public long getWaitTime ( ) { } public void setWaitTime ( long waitTime ) { } public int getMaxMissing ( ) { } public void setMaxMissing ( int maxMissing ) { } public DBHandler getDbHandler ( ) { } public void setDbHandler ( DBHandler dbHandler ) { } No newline ; at end ; of file ; }

Fix:
long reloadSize = ( ( XidManager . getCurrent ( dbHandler , name ) ) - ( spoutGroup . length ) ) + 1 ;