private synchronized void reopen ( String msg , long targetPos , long length ) throws IOException { if ( wrappedStream != null ) { closeStream ( "reopen(" + msg + ")" , contentRangeFinish ) ; } contentRangeStart = targetPos ; contentRangeFinish = targetPos + Math . max ( readahead , length ) + threasholdRead ; if ( negativeSeek < 0 ) { contentRangeFinish = targetPos + Math . abs ( negativeSeek ) ; negativeSeek = 0 ; } try { LOG . trace ( "reopen({}) for {} range[{}-{}], length={}," + " streamPosition={}, nextReadPosition={}" , uri , msg , contentRangeStart , contentRangeFinish , length , pos , nextReadPos ) ; wrappedStream = SwiftAPIDirect . getObject ( new Path ( uri ) , mJossAccount , contentRangeStart , contentRangeFinish , scm ) ; if ( wrappedStream == null ) { throw new IOException ( "Null IO stream from reopen of (" + msg + ") " + uri ) ; } } catch ( ClientException e ) { LOG . error ( e . getMessage ( ) ) ; throw new IOException ( "Reopen at position " + targetPos + uri ) ; } pos = targetPos ; }
Reopen stream if closed