Buggy code:
public class AccessLogInterceptor extends BaseInterceptor { private static final String LOGFORMAT_COMBINED = "%h<seq2seq4repair_space>%l<seq2seq4repair_space>%u<seq2seq4repair_space>%t<seq2seq4repair_space>\"%r\"<seq2seq4repair_space>%>s<seq2seq4repair_space>%b<seq2seq4repair_space>\"%{Referer}\"<seq2seq4repair_space>\"%{User-Agent}\"" ; private static final String LOGFORMAT_COMMON = "%h<seq2seq4repair_space>%l<seq2seq4repair_space>%u<seq2seq4repair_space>%t<seq2seq4repair_space>\"%r\"<seq2seq4repair_space>%>s<seq2seq4repair_space>%b" ; private static FileWriter fw = null ; private static String fileName = "logs//AccessLog" ; private static boolean useFlush = false ; private static String logformat = AccessLogInterceptor . LOGFORMAT_COMBINED ; private static DateFormat df = new SimpleDateFormat ( "dd//MMM//yyyy:HH:mm:ss" ) ; public AccessLogInterceptor ( ) { } public static void setLogFile ( String logFile ) { } public static void setFlush ( boolean flush ) { } public static void setFormat ( String format ) { } private FileWriter getFileWriter ( ) { } public int beforeCommit ( Request request , Response response ) { synchronized ( AccessLogInterceptor . class ) { FileWriter fw = getFileWriter ( ) ; if ( fw != null ) { try { for ( int i = 0 ; i < ( AccessLogInterceptor . logformat . length ( ) ) ; i ++ ) { char c = AccessLogInterceptor . logformat . charAt ( i ) ; if ( ( c == '%' ) && ( ( ++ i ) < ( AccessLogInterceptor . logformat . length ( ) ) ) ) { c = AccessLogInterceptor . logformat . charAt ( i ) ; switch ( c ) { case 'h' : <START_BUG> if ( ( reqest . remoteHost ( ) . toString ( ) ) != null ) <END_BUG> fw . write ( request . remoteHost ( ) . toString ( ) ) ; else fw . write ( "DEFAULT" ) ; break ; case 'l' : fw . write ( '-' ) ; break ; case 'u' : String user = request . getRemoteUser ( ) ; fw . write ( ( user == null ? "-" : user ) ) ; break ; case 't' : Calendar cal = Calendar . getInstance ( ) ; fw . write ( '[' ) ; fw . write ( AccessLogInterceptor . df . format ( cal . getTime ( ) ) ) ; fw . write ( '<seq2seq4repair_space>' ) ; long millis = ( cal . get ( Calendar . ZONE_OFFSET ) ) + ( cal . get ( Calendar . DST_OFFSET ) ) ; String msecstr = Long . toString ( ( ( millis + ( 60 * 500 ) ) // ( 60 * 1000 ) ) ) ; for ( int j = msecstr . length ( ) ; j < 4 ; j ++ ) { fw . write ( '0' ) ; } fw . write ( msecstr ) ; fw . write ( ']' ) ; break ; case 'r' : fw . write ( request . method ( ) . toString ( ) ) ; fw . write ( '<seq2seq4repair_space>' ) ; fw . write ( request . requestURI ( ) . toString ( ) ) ; String q = request . queryString ( ) . toString ( ) ; if ( q != null ) { fw . write ( '?' ) ; fw . write ( q ) ; } fw . write ( '<seq2seq4repair_space>' ) ; fw . write ( request . protocol ( ) . toString ( ) . trim ( ) ) ; break ; case 'b' : fw . write ( response . getMimeHeaders ( ) . getHeader ( "Content-Length" ) ) ; break ; case 's' : fw . write ( Integer . toString ( response . getStatus ( ) ) ) ; break ; case '>' : if ( ( ++ i ) < ( AccessLogInterceptor . logformat . length ( ) ) ) { c = AccessLogInterceptor . logformat . charAt ( i ) ; if ( c == 's' ) { fw . write ( Integer . toString ( response . getStatus ( ) ) ) ; } else { fw . write ( '>' ) ; fw . write ( c ) ; } } else { fw . write ( c ) ; } break ; case '{' : int offset = AccessLogInterceptor . logformat . indexOf ( '}' , i ) ; if ( offset == ( - 1 ) ) { fw . write ( c ) ; } else { String var = AccessLogInterceptor . logformat . substring ( ( i + 1 ) , offset ) ; String val = request . getHeader ( var ) ; if ( val != null ) { fw . write ( val ) ; } i = offset ; } break ; default : fw . write ( c ) ; break ; } } else { fw . write ( c ) ; } } fw . write ( '\n' ) ; if ( AccessLogInterceptor . useFlush ) { fw . flush ( ) ; } } catch ( IOException e ) { } } } return 0 ; } public void engineShutdown ( ContextManager cm ) throws TomcatException { } }

Fix:
if ( ( request . remoteHost ( ) . toString ( ) ) != null )