private void ensureFill ( ) throws JedisConnectionException { if ( count >= limit ) { try { limit = in . read ( buf ) ; count = 0 ; if ( limit == - 1 ) { throw new JedisConnectionException ( "Unexpected end of stream." ) ; } } catch ( IOException e ) { throw new JedisConnectionException ( e ) ; } } }
This methods assumes there are required bytes to be read . If we cannot read anymore bytes an exception is thrown to quickly ascertain that the stream was smaller than expected .