public void closeIfAppropriate ( ) throws JournalException { synchronized ( JournalWriter . SYNCHRONIZER ) { if ( ! open ) { return ; } // if the size limit is 0 or negative, treat it as "no limit". long currentSize = tempFile . length ( ) ; if ( sizeLimit > 0 && currentSize > sizeLimit ) { close ( ) ; } } }
Check the size limit and see whether the file is big enough to close . We could also check the age limit here but we trust the timer to handle that .