Buggy code:
public abstract class BaseWindowBolt extends BaseRichBolt implements IBaseWindowBolt { long MAXFILESIZE ; int WRITEBUFFERSIZE ; int READBUFFERSIZE ; int MAXTHREAD ; int TICKTUPLEFREQUENCY ; long CATCHUPSLEEPTIME ; String FILEPATH ; static final Logger LOG = Logger . getLogger ( BaseWindowBolt . class . getName ( ) ) ; boolean isTimeBased ; long windowStart ; long windowEnd ; long tupleCount ; long slideBy ; protected BlockingQueue < Long > _windowStartAddress ; protected BlockingQueue < Long > _windowEndAddress ; byte [ ] _writeBuffer ; int _bufferIndex ; FileOutputStream _fileWriter ; int secondCount ; OutputCollector _collector ; List < byte [ ] > _bufferList ; Thread [ ] _diskReaderThread ; BlockingQueue < Integer > _threadSequenceQueue ; HashMap < Integer , Integer > _producerConsumerMap ; long startOffset ; RandomAccessFile _fileReader ; Thread _memoryReader ; int cleanUp ; public BaseWindowBolt ( WindowObject wObj ) { } public void prepare ( Map conf , TopologyContext context , OutputCollector collector ) { } public void execute ( Tuple tuple ) { } protected abstract void delegateExecute ( Tuple tuple ) { } public void declareOutputFields ( OutputFieldsDeclarer declarer ) { } public boolean isTickTuple ( Tuple tuple ) { } private void sendEndOfWindowSignal ( ) { } public void initiateEmitter ( ) throws InterruptedException { } @ Override public void cleanup ( ) { } @ Override public Map < String , Object > getComponentConfiguration ( ) { } protected void addStartAddress ( Long address ) { } protected void addEndAddress ( Long address ) { } public void storeTuple ( Tuple tuple , int flag , int count ) { } private void writeInParts ( ) throws IOException { } private void Emitter ( ) throws InterruptedException { } private class DiskToMemory extends Thread { int __threadSequence ; long __start1 ; long __end1 ; long __start2 ; long __end2 ; boolean __sendEOWSignal ; boolean __isWrapLoadNeeded ; public DiskToMemory ( int threadSeq ) { } public void run ( ) { } private boolean EmptyWindow ( long start , long end ) { } private int loadBuffer ( long s , long e , int index ) throws IOException { } } private class EmitFromMemory extends Thread { int __currentBuffer ; int __bufferIndex ; int __length ; byte __ten ; byte __unit ; public EmitFromMemory ( ) { } public void run ( ) { } private int getIntFromTwoBytes ( byte tens , byte units ) { } private void getLength ( ) { } private void emitTuple ( ) { if ( ( __length ) == 0 ) { _producerConsumerMap . put ( __currentBuffer , ( - 1 ) ) ; ( __currentBuffer ) ++ ; __currentBuffer = ( __currentBuffer ) % ( MAXTHREAD ) ; while ( ( _producerConsumerMap . get ( __currentBuffer ) ) == ( - 1 ) ) ; __bufferIndex = 0 ; return ; } else if ( ( __length ) == ( - 1 ) ) { _producerConsumerMap . put ( __currentBuffer , ( - 1 ) ) ; sendEndOfWindowSignal ( ) ; ( __currentBuffer ) ++ ; __currentBuffer = ( __currentBuffer ) % ( MAXTHREAD ) ; while ( ( _producerConsumerMap . get ( __currentBuffer ) ) == ( - 1 ) ) ; __bufferIndex = 0 ; return ; } else if ( ( ( __bufferIndex ) + ( __length ) ) <= ( READBUFFERSIZE ) ) { byte [ ] tempArray = new byte [ __length ] ; System . arraycopy ( _bufferList . get ( __currentBuffer ) , __bufferIndex , tempArray , 0 , __length ) ; String tupleData = new String ( tempArray , Charsets . UTF_8 ) ; _collector . emit ( "dataStream" , new Values ( tupleData ) ) ; __bufferIndex = ( __bufferIndex ) + ( __length ) ; return ; } else { byte [ ] tempArray = new byte [ __length ] ; int partLength = ( READBUFFERSIZE ) - ( __bufferIndex ) ; System . arraycopy ( _bufferList . get ( __currentBuffer ) , __bufferIndex , tempArray , 0 , partLength ) ; _producerConsumerMap . put ( __currentBuffer , ( - 1 ) ) ; ( __currentBuffer ) ++ ; __currentBuffer = ( __currentBuffer ) % ( MAXTHREAD ) ; while ( ( _producerConsumerMap . get ( __currentBuffer ) ) == ( - 1 ) ) ; __bufferIndex = 0 ; __length = ( __length ) - partLength ; System . arraycopy ( _bufferList . get ( __currentBuffer ) , __bufferIndex , tempArray , partLength , __length ) ; <START_BUG> String tupleData = new String ( tempArray ) ; <END_BUG> _collector . emit ( "dataStream" , new Values ( tupleData ) ) ; __bufferIndex = ( __bufferIndex ) + ( __length ) ; return ; } } } No newline ; at end ; of file ; }

Fix:
String tupleData = new String ( tempArray , Charsets . UTF_8 ) ;