Buggy code:
public abstract class FileUploadBase { public static final boolean isMultipartContent ( RequestContext ctx ) { } public static final String CONTENT_TYPE = "Content-type" ; public static final String CONTENT_DISPOSITION = "Content-disposition" ; public static final String FORM_DATA = "form-data" ; public static final String ATTACHMENT = "attachment" ; public static final String MULTIPART = "multipart//" ; public static final String MULTIPART_FORM_DATA = "multipart//form-data" ; public static final String MULTIPART_MIXED = "multipart//mixed" ; public static final int MAX_HEADER_SIZE = 1024 ; private long sizeMax = - 1 ; private String headerEncoding ; public abstract FileItemFactory getFileItemFactory ( ) { } public abstract void setFileItemFactory ( FileItemFactory factory ) { } public long getSizeMax ( ) { } public void setSizeMax ( long sizeMax ) { } public String getHeaderEncoding ( ) { } public void setHeaderEncoding ( String encoding ) { } public List parseRequest ( RequestContext ctx ) throws FileUploadException { if ( ctx == null ) { throw new IllegalArgumentException ( "ctx<seq2seq4repair_space>parameter<seq2seq4repair_space>cannot<seq2seq4repair_space>be<seq2seq4repair_space>null" ) ; } ArrayList items = new ArrayList ( ) ; String contentType = ctx . getContentType ( ) ; if ( ( null == contentType ) || ( ! ( contentType . toLowerCase ( ) . startsWith ( FileUploadBase . MULTIPART ) ) ) ) { throw new FileUploadBase . InvalidContentTypeException ( ( ( ( ( ( "the<seq2seq4repair_space>request<seq2seq4repair_space>doesn't<seq2seq4repair_space>contain<seq2seq4repair_space>a<seq2seq4repair_space>" + ( FileUploadBase . MULTIPART_FORM_DATA ) ) + "<seq2seq4repair_space>or<seq2seq4repair_space>" ) + ( FileUploadBase . MULTIPART_MIXED ) ) + "<seq2seq4repair_space>stream,<seq2seq4repair_space>content<seq2seq4repair_space>type<seq2seq4repair_space>header<seq2seq4repair_space>is<seq2seq4repair_space>" ) + contentType ) ) ; } int requestSize = ctx . getContentLength ( ) ; if ( requestSize == ( - 1 ) ) { throw new FileUploadBase . UnknownSizeException ( "the<seq2seq4repair_space>request<seq2seq4repair_space>was<seq2seq4repair_space>rejected<seq2seq4repair_space>because<seq2seq4repair_space>its<seq2seq4repair_space>size<seq2seq4repair_space>is<seq2seq4repair_space>unknown" ) ; } if ( ( ( sizeMax ) >= 0 ) && ( requestSize > ( sizeMax ) ) ) { throw new FileUploadBase . SizeLimitExceededException ( ( "the<seq2seq4repair_space>request<seq2seq4repair_space>was<seq2seq4repair_space>rejected<seq2seq4repair_space>because<seq2seq4repair_space>" + "its<seq2seq4repair_space>size<seq2seq4repair_space>exceeds<seq2seq4repair_space>allowed<seq2seq4repair_space>range" ) ) ; } try { byte [ ] boundary = getBoundary ( contentType ) ; if ( boundary == null ) { throw new FileUploadException ( ( "the<seq2seq4repair_space>request<seq2seq4repair_space>was<seq2seq4repair_space>rejected<seq2seq4repair_space>because<seq2seq4repair_space>" + "no<seq2seq4repair_space>multipart<seq2seq4repair_space>boundary<seq2seq4repair_space>was<seq2seq4repair_space>found" ) ) ; } InputStream input = ctx . getInputStream ( ) ; <START_BUG> MultipartStream multi = new MultipartStream ( input , boundary ) ; <END_BUG> multi . setHeaderEncoding ( headerEncoding ) ; boolean nextPart = multi . skipPreamble ( ) ; while ( nextPart ) { Map headers = parseHeaders ( multi . readHeaders ( ) ) ; String fieldName = getFieldName ( headers ) ; if ( fieldName != null ) { String subContentType = getHeader ( headers , FileUploadBase . CONTENT_TYPE ) ; if ( ( subContentType != null ) && ( subContentType . toLowerCase ( ) . startsWith ( FileUploadBase . MULTIPART_MIXED ) ) ) { byte [ ] subBoundary = getBoundary ( subContentType ) ; multi . setBoundary ( subBoundary ) ; boolean nextSubPart = multi . skipPreamble ( ) ; while ( nextSubPart ) { headers = parseHeaders ( multi . readHeaders ( ) ) ; if ( ( getFileName ( headers ) ) != null ) { FileItem item = createItem ( headers , false ) ; OutputStream os = item . getOutputStream ( ) ; try { multi . readBodyData ( os ) ; } finally { os . close ( ) ; } items . add ( item ) ; } else { multi . discardBodyData ( ) ; } nextSubPart = multi . readBoundary ( ) ; } multi . setBoundary ( boundary ) ; } else { FileItem item = createItem ( headers , ( ( getFileName ( headers ) ) == null ) ) ; OutputStream os = item . getOutputStream ( ) ; try { multi . readBodyData ( os ) ; } finally { os . close ( ) ; } items . add ( item ) ; } } else { multi . discardBodyData ( ) ; } nextPart = multi . readBoundary ( ) ; } } catch ( IOException e ) { throw new FileUploadException ( ( ( ( "Processing<seq2seq4repair_space>of<seq2seq4repair_space>" + ( FileUploadBase . MULTIPART_FORM_DATA ) ) + "<seq2seq4repair_space>request<seq2seq4repair_space>failed.<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; } return items ; } protected byte [ ] getBoundary ( String contentType ) { } protected String getFileName ( Map headers ) { } protected String getFieldName ( Map headers ) { } protected FileItem createItem ( Map headers , boolean isFormField ) { } protected Map parseHeaders ( String headerPart ) { } protected final String getHeader ( Map headers , String name ) { } public static class InvalidContentTypeException extends FileUploadException { private static final long serialVersionUID = 1L ; public InvalidContentTypeException ( ) { } public InvalidContentTypeException ( String message ) { } } public static class UnknownSizeException extends FileUploadException { private static final long serialVersionUID = 1L ; public UnknownSizeException ( ) { } public UnknownSizeException ( String message ) { } } public static class SizeLimitExceededException extends FileUploadException { private static final long serialVersionUID = 1L ; public SizeLimitExceededException ( ) { } public SizeLimitExceededException ( String message ) { } } }

Fix:
MultipartFormInputStream multi = new MultipartFormInputStream ( input , boundary ) ;