protected void checkLimits ( ) throws RecorderIOException { // too much material before finding end of headers? if ( messageBodyBeginMark < 0 ) { // no mark yet if ( position > MAX_HEADER_MATERIAL ) { throw new RecorderTooMuchHeaderException ( ) ; } } // overlong? if ( position > maxLength ) { throw new RecorderLengthExceededException ( ) ; } // taking too long? long duration = System . currentTimeMillis ( ) - startTime ; duration = Math . max ( duration , 1 ) ; // !divzero if ( duration > timeoutMs ) { throw new RecorderTimeoutException ( ) ; } // need to throttle reading to hit max configured rate? if ( position / duration >= maxRateBytesPerMs ) { long desiredDuration = position / maxRateBytesPerMs ; try { Thread . sleep ( desiredDuration - duration ) ; } catch ( InterruptedException e ) { logger . log ( Level . WARNING , "bandwidth throttling sleep interrupted" , e ) ; } } }
Check any enforced limits .