@Override public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException {
  LengthOfOutputStream stream=(LengthOfOutputStream)writerInterceptorContext.getProperty(PROPERTY_OUTPUT_STREAM);
  try {
    writerInterceptorContext.proceed();
    if (stream != null) {
      emitSuccess(stream);
    }
  }
 catch (  EOFException e) {
    if (stream != null) {
      emitError(stream,e);
    }
    LOG.warn("Connection to client closed prematurely.",e);
  }
catch (  Error|RuntimeException|IOException e) {
    if (stream != null) {
      emitError(stream,e);
    }
    LOG.error("Error encountered while streaming response back to the client.",e);
    throw e;
  }
 finally {
    try {
      RequestLog.stopTiming(this);
      RequestLog.stopTiming(TOTAL_TIMER);
      RequestLog.log();
    }
 catch (    Exception e) {
      LOG.error("Error finalizing the BardLoggingFilter output stream wrapper.",e);
    }
  }
}

@ Override public void aroundWriteTo ( WriterInterceptorContext writerInterceptorContext ) throws IOException { LengthOfOutputStream stream = ( LengthOfOutputStream ) writerInterceptorContext . getProperty ( PROPERTY_OUTPUT_STREAM ) ; try { writerInterceptorContext . proceed ( ) ; if ( stream != null ) { emitSuccess ( stream ) ; } } catch ( EOFException e ) { if ( stream != null ) { emitError ( stream , e ) ; } LOG . warn ( "Connection to client closed prematurely." , e ) ; } catch ( Error | RuntimeException | IOException e ) { if ( stream != null ) { emitError ( stream , e ) ; } LOG . error ( "Error encountered while streaming response back to the client." , e ) ; throw e ; } finally { try { RequestLog . stopTiming ( this ) ; RequestLog . stopTiming ( TOTAL_TIMER ) ; RequestLog . log ( ) ; } catch ( Exception e ) { LOG . error ( "Error finalizing the BardLoggingFilter output stream wrapper." , e ) ; } } }
this allows us to compute the length of the output stream when stream is closed .
