This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch 1.x in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
commit ff66d1f8e8d6e3456f891b664f8c65c285253f52 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sun May 4 14:40:24 2025 -0400 Reduce vertical whitespace --- .../apache/commons/fileupload/FileUploadBase.java | 46 ++++++++-------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java index 0a42e514..725585f7 100644 --- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java +++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java @@ -307,73 +307,59 @@ public abstract class FileUploadBase { * parsing the request. * @throws IOException An I/O error occurred. */ - FileItemIteratorImpl(final RequestContext ctx) - throws FileUploadException, IOException { + FileItemIteratorImpl(final RequestContext ctx) throws FileUploadException, IOException { Objects.requireNonNull(ctx, "ctx"); final String contentType = ctx.getContentType(); - if (null == contentType - || !contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART)) { - throw new InvalidContentTypeException( - format("the request neither contains a %s nor a %s nor a %s stream, content type header is %s", - MULTIPART_FORM_DATA, MULTIPART_MIXED, MULTIPART_RELATED, contentType)); + if (null == contentType || !contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART)) { + throw new InvalidContentTypeException(format("the request neither contains a %s nor a %s nor a %s stream, content type header is %s", + MULTIPART_FORM_DATA, MULTIPART_MIXED, MULTIPART_RELATED, contentType)); } - multipartRelated = contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART_RELATED); - @SuppressWarnings("deprecation") // still has to be backward compatible final int contentLengthInt = ctx.getContentLength(); - final long requestSize = UploadContext.class.isAssignableFrom(ctx.getClass()) - // Inline conditional is OK here CHECKSTYLE:OFF - ? ((UploadContext) ctx).contentLength() - : contentLengthInt; - // CHECKSTYLE:ON - + // Inline conditional is OK here CHECKSTYLE:OFF + ? ((UploadContext) ctx).contentLength() + : contentLengthInt; + // CHECKSTYLE:ON final InputStream input; // this is eventually closed in MultipartStream processing if (sizeMax >= 0) { if (requestSize != -1 && requestSize > sizeMax) { - throw new SizeLimitExceededException( - format("the request was rejected because its size (%s) exceeds the configured maximum (%s)", - Long.valueOf(requestSize), Long.valueOf(sizeMax)), - requestSize, sizeMax); + throw new SizeLimitExceededException(format("the request was rejected because its size (%s) exceeds the configured maximum (%s)", + Long.valueOf(requestSize), Long.valueOf(sizeMax)), requestSize, sizeMax); } // this is eventually closed in MultipartStream processing input = new LimitedInputStream(ctx.getInputStream(), sizeMax) { + @Override - protected void raiseError(final long sizeMax, final long count) - throws IOException { + protected void raiseError(final long sizeMax, final long count) throws IOException { final FileUploadException ex = new SizeLimitExceededException( - format("the request was rejected because its size (%s) exceeds the configured maximum (%s)", - Long.valueOf(count), Long.valueOf(sizeMax)), - count, sizeMax); + format("the request was rejected because its size (%s) exceeds the configured maximum (%s)", Long.valueOf(count), + Long.valueOf(sizeMax)), + count, sizeMax); throw new FileUploadIOException(ex); } }; } else { input = ctx.getInputStream(); } - String charEncoding = headerEncoding; if (charEncoding == null) { charEncoding = ctx.getCharacterEncoding(); } - boundary = getBoundary(contentType); if (boundary == null) { IOUtils.closeQuietly(input); // avoid possible resource leak throw new FileUploadException("the request was rejected because no multipart boundary was found"); } - notifier = new MultipartStream.ProgressNotifier(listener, requestSize); try { multi = new MultipartStream(input, boundary, notifier); } catch (final IllegalArgumentException iae) { IOUtils.closeQuietly(input); // avoid possible resource leak - throw new InvalidContentTypeException( - format("The boundary specified in the %s header is too long", CONTENT_TYPE), iae); + throw new InvalidContentTypeException(format("The boundary specified in the %s header is too long", CONTENT_TYPE), iae); } multi.setHeaderEncoding(charEncoding); - skipPreamble = true; findNextItem(); }