@ FFDCIgnore ( { IOException . class } ) private void convertFile ( FileChannel fc ) throws IOException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Converting FileChannel to buffers" ) ; } final WsByteBuffer [ ] body = new WsByteBuffer [ 1 ] ; final WsByteBufferPoolManager mgr = HttpDispatcher . getBufferManager ( ) ; final long max = fc . size ( ) ; final long blocksize = ( 1048576L < max ) ? 1048576L : max ; long offset = 0 ; while ( offset < max ) { ByteBuffer bb = fc . map ( MapMode . READ_ONLY , offset , blocksize ) ; offset += blocksize ; WsByteBuffer wsbb = mgr . wrap ( bb ) ; body [ 0 ] = wsbb ; try { this . isc . sendResponseBody ( body ) ; } catch ( MessageSentException mse ) { FFDCFilter . processException ( mse , getClass ( ) . getName ( ) , "convertFile" , new Object [ ] { this , this . isc } ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Invalid state, message-sent-exception received; " + this . isc ) ; } this . error = new IOException ( "Invalid state" ) ; throw this . error ; } catch ( IOException ioe ) { // no FFDC required this . error = ioe ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Received exception during write: " + ioe ) ; } throw ioe ; } finally { wsbb . release ( ) ; } } // end-while }
User attempted to use the optimized FileChannel writing ; however that path is currently disabled . This method will read the file and do repeated write calls until done . This avoids TCP channel doing it in one big block .