Buggy code:
public class TransactionalWords { public static class CountValue { Integer prev_count = null ; int count = 0 ; BigInteger txid = null ; } public static class BucketValue { int count = 0 ; BigInteger txid ; } public static final int BUCKET_SIZE = 10 ; public static Map < String , TransactionalWords . CountValue > COUNT_DATABASE = new HashMap < String , TransactionalWords . CountValue > ( ) ; public static Map < Integer , TransactionalWords . BucketValue > BUCKET_DATABASE = new HashMap < Integer , TransactionalWords . BucketValue > ( ) ; public static final int PARTITION_TAKE_PER_BATCH = 3 ; public static final Map < Integer , List < List < Object > > > DATA = new HashMap < Integer , List < List < Object > > > ( ) { } ; public static class KeyedCountUpdater extends BaseTransactionalBolt implements ICommitter { Map < String , Integer > _counts = new HashMap < String , Integer > ( ) ; BatchOutputCollector _collector ; TransactionAttempt _id ; int _count = 0 ; @ Override public void prepare ( Map conf , TopologyContext context , BatchOutputCollector collector , TransactionAttempt id ) { } @ Override public void execute ( Tuple tuple ) { } @ Override public void finishBatch ( ) { for ( String key : _counts . keySet ( ) ) { TransactionalWords . CountValue val = TransactionalWords . COUNT_DATABASE . get ( key ) ; TransactionalWords . CountValue newVal ; if ( ( val == null ) || ( ! ( val . txid . equals ( _id ) ) ) ) { newVal = new TransactionalWords . CountValue ( ) ; newVal . txid = _id . getTransactionId ( ) ; if ( val != null ) { newVal . prev_count = val . count ; newVal . count = val . count ; } newVal . count = ( newVal . count ) + ( _counts . get ( key ) ) ; <START_BUG> TransactionalWords . COUNT_DATABASE . put ( key , val ) ; <END_BUG> } else { newVal = val ; } _collector . emit ( new backtype . storm . tuple . Values ( _id , key , newVal . count , newVal . prev_count ) ) ; } } @ Override public void declareOutputFields ( OutputFieldsDeclarer declarer ) { } } public static class Bucketize extends BaseBasicBolt { @ Override public void execute ( Tuple tuple , BasicOutputCollector collector ) { } @ Override public void declareOutputFields ( OutputFieldsDeclarer declarer ) { } } public static class BucketCountUpdater extends BaseTransactionalBolt { Map < Integer , Integer > _accum = new HashMap < Integer , Integer > ( ) ; BatchOutputCollector _collector ; TransactionAttempt _attempt ; int _count = 0 ; @ Override public void prepare ( Map conf , TopologyContext context , BatchOutputCollector collector , TransactionAttempt attempt ) { } @ Override public void execute ( Tuple tuple ) { } @ Override public void finishBatch ( ) { for ( Integer bucket : _accum . keySet ( ) ) { TransactionalWords . BucketValue currVal = TransactionalWords . BUCKET_DATABASE . get ( bucket ) ; TransactionalWords . BucketValue newVal ; if ( ( currVal == null ) || ( ! ( currVal . txid . equals ( _attempt . getTransactionId ( ) ) ) ) ) { newVal = new TransactionalWords . BucketValue ( ) ; newVal . txid = _attempt . getTransactionId ( ) ; newVal . count = _accum . get ( bucket ) ; if ( currVal != null ) newVal . count += currVal . count ; TransactionalWords . BUCKET_DATABASE . put ( bucket , newVal ) ; } else { newVal = currVal ; } _collector . emit ( new backtype . storm . tuple . Values ( _attempt , bucket , newVal . count ) ) ; } } @ Override public void declareOutputFields ( OutputFieldsDeclarer declarer ) { } } public static void main ( String [ ] args ) throws Exception { } }

Fix:
TransactionalWords . COUNT_DATABASE . put ( key , newVal ) ;