private void append ( byte [ ] data ) { if ( storage . position ( ) + data . length >= storage . capacity ( ) ) { ByteBuffer tmp = ByteBuffer . allocate ( storage . limit ( ) + data . length * 2 ) ; byte [ ] tmpData = new byte [ storage . position ( ) ] ; storage . flip ( ) ; storage . get ( tmpData ) ; tmp . put ( tmpData ) ; storage = tmp ; logger . warn ( "Increase storage size. Current size is {}" , storage . array ( ) . length ) ; } try { storage . put ( data ) ; } catch ( BufferOverflowException boe ) { logger . error ( "Buffer overflow occured" , boe ) ; } boolean messageReceived ; do { messageReceived = seekMessage ( ) ; } while ( messageReceived ) ; }
Adds data to storage