Buggy code:
private static final DefaultServlet . SecureEntityResolver secureEntityResolver ; protected int debug = 0 ; protected int input = 2048 ; protected boolean listings = false ; protected boolean readOnly = true ; protected int output = 2048 ; protected static final URLEncoder urlEncoder ; protected String localXsltFile = null ; protected String contextXsltFile = null ; protected String globalXsltFile = null ; protected String readmeFile = null ; protected transient ProxyDirContext resources = null ; protected String fileEncoding = null ; protected int sendfileSize = 48 * 1024 ; protected boolean useAcceptRanges = true ; protected static final ArrayList < DefaultServlet . Range > FULL = new ArrayList < DefaultServlet . Range > ( ) ; protected boolean showServerInfo = true ; protected static final String mimeSeparation = "CATALINA_MIME_BOUNDARY" ; protected static final String RESOURCES_JNDI_NAME = "java://comp//Resources" ; protected static final StringManager sm = StringManager . getManager ( Package ) ; protected static final int BUFFER_SIZE = 4096 ; @ Override public void destroy ( ) { } @ Override public void init ( ) throws ServletException { } protected String getRelativePath ( HttpServletRequest request ) { } protected String getRelativePath ( HttpServletRequest request , boolean allowEmptyPath ) { } protected String getPathPrefix ( final HttpServletRequest request ) { } @ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } @ Override protected void doHead ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } @ Override protected void doOptions ( HttpServletRequest req , HttpServletResponse resp ) throws IOException , ServletException { } @ Override protected void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } @ Override protected void doPut ( HttpServletRequest req , HttpServletResponse resp ) throws IOException , ServletException { } protected File executePartialPut ( HttpServletRequest req , DefaultServlet . Range range , String path ) throws IOException { } @ Override protected void doDelete ( HttpServletRequest req , HttpServletResponse resp ) throws IOException , ServletException { } protected boolean checkIfHeaders ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) throws IOException { } protected String rewriteUrl ( String path ) { } @ Deprecated protected void displaySize ( StringBuilder buf , int filesize ) { } protected void serveResource ( HttpServletRequest request , HttpServletResponse response , boolean content ) throws IOException , ServletException { } private void doDirectoryRedirect ( HttpServletRequest request , HttpServletResponse response ) throws IOException { } protected DefaultServlet . Range parseContentRange ( HttpServletRequest request , HttpServletResponse response ) throws IOException { } protected ArrayList < DefaultServlet . Range > parseRange ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) throws IOException { } protected InputStream render ( String contextPath , CacheEntry cacheEntry ) throws IOException , ServletException { } protected InputStream renderXml ( String contextPath , CacheEntry cacheEntry , Source xsltSource ) throws IOException , ServletException { } protected InputStream renderHtml ( String contextPath , CacheEntry cacheEntry ) throws IOException , ServletException { } protected String renderSize ( long size ) { } protected String getReadme ( DirContext directory ) throws IOException { } protected Source findXsltInputStream ( DirContext directory ) throws IOException { } private File validateGlobalXsltFile ( ) { } private File validateGlobalXsltFile ( File base ) { } private Source secureXslt ( InputStream is ) { } protected boolean checkSendfile ( HttpServletRequest request , HttpServletResponse response , CacheEntry entry , long length , DefaultServlet . Range range ) { <START_BUG> if ( ( ( ( ( ( ( ( sendfileSize ) > 0 ) && ( ( entry . resource ) != null ) ) && ( ( length > ( sendfileSize ) ) || ( ( entry . resource . getContent ( ) ) == null ) ) ) && ( ( entry . attributes . getCanonicalPath ( ) ) != null ) ) && ( ( Boolean . TRUE ) == ( request . getAttribute ( SENDFILE_SUPPORTED_ATTR ) ) ) ) && ( request . getClass ( ) . getName ( ) . equals ( "org.apache.catalina.connector.RequestFacade" ) ) ) && ( response . getClass ( ) . getName ( ) . equals ( "org.apache.catalina.connector.ResponseFacade" ) ) ) { <END_BUG> request . setAttribute ( SENDFILE_FILENAME_ATTR , entry . attributes . getCanonicalPath ( ) ) ; if ( range == null ) { request . setAttribute ( SENDFILE_FILE_START_ATTR , Long . valueOf ( 0L ) ) ; request . setAttribute ( SENDFILE_FILE_END_ATTR , Long . valueOf ( length ) ) ; } else { request . setAttribute ( SENDFILE_FILE_START_ATTR , Long . valueOf ( range . start ) ) ; request . setAttribute ( SENDFILE_FILE_END_ATTR , Long . valueOf ( ( ( range . end ) + 1 ) ) ) ; } return true ; } return false ; } protected boolean checkIfMatch ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) throws IOException { } protected boolean checkIfModifiedSince ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) { } protected boolean checkIfNoneMatch ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) throws IOException { } protected boolean checkIfUnmodifiedSince ( HttpServletRequest request , HttpServletResponse response , ResourceAttributes resourceAttributes ) throws IOException { } protected void copy ( CacheEntry cacheEntry , InputStream is , ServletOutputStream ostream ) throws IOException { } protected void copy ( CacheEntry cacheEntry , InputStream is , PrintWriter writer ) throws IOException { } protected void copy ( CacheEntry cacheEntry , ServletOutputStream ostream , DefaultServlet . Range range ) throws IOException { } protected void copy ( CacheEntry cacheEntry , ServletOutputStream ostream , Iterator < DefaultServlet . Range > ranges , String contentType ) throws IOException { } protected IOException copyRange ( InputStream istream , ServletOutputStream ostream ) { } protected IOException copyRange ( Reader reader , PrintWriter writer ) { } protected IOException copyRange ( InputStream istream , ServletOutputStream ostream , long start , long end ) { } protected static class Range { public long start ; public long end ;

Fix:
if ( ( ( ( ( ( ( ( sendfileSize ) > 0 ) && ( ( entry . resource ) != null ) ) && ( ( length > ( sendfileSize ) ) || ( ( entry . resource . getContent ( ) ) == null ) ) ) && ( ( entry . attributes . getCanonicalPath ( ) ) != null ) ) && ( Boolean . TRUE . equals ( request . getAttribute ( SENDFILE_SUPPORTED_ATTR ) ) ) ) && ( request . getClass ( ) . getName ( ) . equals ( "org.apache.catalina.connector.RequestFacade" ) ) ) && ( response . getClass ( ) . getName ( ) . equals ( "org.apache.catalina.connector.ResponseFacade" ) ) ) {