Buggy code:
class AJP12RequestAdapter extends Request { static StringManager sm = StringManager . getManager ( "org.apache.tomcat.resources" ) ; Socket socket ; InputStream sin ; BufferedInputStream ajpin ; boolean shutdown = false ; boolean isPing = false ; boolean doLog ; void d ( String s ) { } public int doRead ( ) throws IOException { } public int doRead ( byte [ ] b , int off , int len ) throws IOException { } public AJP12RequestAdapter ( ) { } public void setContextManager ( ContextManager cm ) { } public void setSocket ( Socket s ) throws IOException { } public AJP12RequestAdapter ( ContextManager cm , Socket s ) throws IOException { } protected void readNextRequest ( ) throws IOException { String dummy ; String token1 ; String token2 ; int marker ; int signal ; try { boolean more = true ; while ( more ) { marker = ajpin . read ( ) ; switch ( marker ) { case 0 : break ; case 1 : methodMB . setString ( readString ( ajpin , null ) ) ; contextMB . setString ( readString ( ajpin , null ) ) ; if ( contextMB . equalsIgnoreCase ( "ROOT" ) ) contextMB . setString ( null ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>CP=" + ( contextMB . toString ( ) ) ) ) ; dummy = readString ( ajpin , null ) ; serverName = readString ( ajpin , null ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>serverName=" + ( serverName ) ) ) ; dummy = readString ( ajpin , null ) ; pathInfoMB . setString ( readString ( ajpin , null ) ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>PI=" + ( pathInfoMB . toString ( ) ) ) ) ; dummy = readString ( ajpin , null ) ; queryMB . setString ( readString ( ajpin , null ) ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>QS=" + ( queryMB . toString ( ) ) ) ) ; remoteAddr = readString ( ajpin , "" ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>RA=" + ( remoteAddr ) ) ) ; remoteHost = readString ( ajpin , "" ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>RH=" + ( remoteHost ) ) ) ; remoteUser = readString ( ajpin , null ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>RU=" + ( remoteUser ) ) ) ; authType = readString ( ajpin , null ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>AT=" + ( authType ) ) ) ; dummy = readString ( ajpin , null ) ; methodMB . setString ( readString ( ajpin , null ) ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>Meth=" + ( methodMB . toString ( ) ) ) ) ; uriMB . setString ( readString ( ajpin , "" ) ) ; if ( doLog ) d ( ( ( ( "AJP:<seq2seq4repair_space>URI:<seq2seq4repair_space>" + ( uriMB ) ) + "<seq2seq4repair_space>CP:" ) + ( contextMB ) ) ) ; dummy = readString ( ajpin , null ) ; dummy = readString ( ajpin , null ) ; serverName = readString ( ajpin , "" ) ; if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>serverName=" + ( serverName ) ) ) ; try { serverPort = Integer . parseInt ( readString ( ajpin , "80" ) ) ; } catch ( Exception any ) { serverPort = 80 ; } dummy = readString ( ajpin , "" ) ; dummy = readString ( ajpin , "" ) ; dummy = readString ( ajpin , "" ) ; jvmRoute = readString ( ajpin , "" ) ; if ( ( jvmRoute . length ( ) ) == 0 ) { jvmRoute = null ; } if ( doLog ) d ( ( "AJP:<seq2seq4repair_space>Server<seq2seq4repair_space>jvmRoute=" + ( jvmRoute ) ) ) ; dummy = readString ( ajpin , "" ) ; dummy = readString ( ajpin , "" ) ; break ; case 5 : token1 = readString ( ajpin , null ) ; token2 = readString ( ajpin , "" ) ; attributes . put ( token1 , token2 ) ; if ( ( token1 . equals ( "HTTPS" ) ) && ( token2 . equals ( "on" ) ) ) { <START_BUG> setScheme ( "https" ) ; <END_BUG> } break ; case 3 : token1 = readString ( ajpin , null ) ; token2 = readString ( ajpin , "" ) ; headers . addValue ( token1 ) . setString ( token2 ) ; break ; case 254 : signal = ajpin . read ( ) ; if ( signal == 0 ) { try { socket . getOutputStream ( ) . write ( 0 ) ; sin . close ( ) ; } catch ( IOException ignored ) { contextM . log ( "Exception<seq2seq4repair_space>closing,<seq2seq4repair_space>ignored" , ignored ) ; } isPing = true ; return ; } else { try { InetAddress serverAddr = socket . getLocalAddress ( ) ; InetAddress clientAddr = socket . getInetAddress ( ) ; sin . close ( ) ; if ( ( signal == 15 ) && ( isSameAddress ( serverAddr , clientAddr ) ) ) { contextM . stop ( ) ; System . exit ( 0 ) ; shutdown = true ; return ; } } catch ( Exception ignored ) { contextM . log ( ( "Ignored<seq2seq4repair_space>exception<seq2seq4repair_space>processing<seq2seq4repair_space>signal<seq2seq4repair_space>" + signal ) , ignored ) ; } } return ; case 4 : case 255 : more = false ; break ; case - 1 : throw new IOException ( "Stream<seq2seq4repair_space>closed<seq2seq4repair_space>prematurely" ) ; default : throw new IOException ( "Stream<seq2seq4repair_space>broken" ) ; } } } catch ( IOException ioe ) { throw ioe ; } catch ( Exception e ) { contextM . log ( "Uncaught<seq2seq4repair_space>exception<seq2seq4repair_space>handling<seq2seq4repair_space>request" , e ) ; } String requestURI = uriMB . toString ( ) ; int indexQ = requestURI . indexOf ( "?" ) ;

Fix:
this . scheme ( ) . setString ( "https" ) ;