This is an automated email from the ASF dual-hosted git repository. jochen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/master by this push: new 1b165d1 FILEUPLOAD-332 - Replace File Tab. Character with spaces new 60841db Merge pull request #84 from arturobernalg/feature/FILEUPLOAD-332 1b165d1 is described below commit 1b165d173ba2ef245dd010e1e04aaa4f75473148 Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Fri May 7 06:19:55 2021 +0200 FILEUPLOAD-332 - Replace File Tab. Character with spaces --- .../commons/fileupload2/FileItemIterator.java | 74 ++++---- .../fileupload2/impl/FileItemIteratorImpl.java | 68 +++---- .../fileupload2/impl/FileItemStreamImpl.java | 4 +- .../apache/commons/fileupload2/util/Streams.java | 2 +- .../commons/fileupload2/DiskFileUploadTest.java | 6 +- .../jaksrvlt/JakSrvltFileUploadTest.java | 2 +- .../jaksrvlt/MockJakSrvltHttpRequest.java | 200 ++++++++++----------- .../fileupload2/servlet/ServletFileUploadTest.java | 2 +- 8 files changed, 179 insertions(+), 179 deletions(-) diff --git a/src/main/java/org/apache/commons/fileupload2/FileItemIterator.java b/src/main/java/org/apache/commons/fileupload2/FileItemIterator.java index 9413805..ae97bc0 100644 --- a/src/main/java/org/apache/commons/fileupload2/FileItemIterator.java +++ b/src/main/java/org/apache/commons/fileupload2/FileItemIterator.java @@ -27,46 +27,46 @@ import org.apache.commons.fileupload2.impl.SizeLimitExceededException; * {@link FileUploadBase#getItemIterator(RequestContext)}. */ public interface FileItemIterator { - /** Returns the maximum size of a single file. An {@link FileSizeLimitExceededException} - * will be thrown, if there is an uploaded file, which is exceeding this value. - * By default, this value will be copied from the {@link FileUploadBase#getFileSizeMax() - * FileUploadBase} object, however, the user may replace the default value with a - * request specific value by invoking {@link #setFileSizeMax(long)} on this object. - * @return The maximum size of a single, uploaded file. The value -1 indicates "unlimited". - */ - long getFileSizeMax(); + /** Returns the maximum size of a single file. An {@link FileSizeLimitExceededException} + * will be thrown, if there is an uploaded file, which is exceeding this value. + * By default, this value will be copied from the {@link FileUploadBase#getFileSizeMax() + * FileUploadBase} object, however, the user may replace the default value with a + * request specific value by invoking {@link #setFileSizeMax(long)} on this object. + * @return The maximum size of a single, uploaded file. The value -1 indicates "unlimited". + */ + long getFileSizeMax(); - /** Sets the maximum size of a single file. An {@link FileSizeLimitExceededException} - * will be thrown, if there is an uploaded file, which is exceeding this value. - * By default, this value will be copied from the {@link FileUploadBase#getFileSizeMax() - * FileUploadBase} object, however, the user may replace the default value with a - * request specific value by invoking {@link #setFileSizeMax(long)} on this object, so - * there is no need to configure it here. - * <em>Note:</em>Changing this value doesn't affect files, that have already been uploaded. - * @param pFileSizeMax The maximum size of a single, uploaded file. The value -1 indicates "unlimited". - */ - void setFileSizeMax(long pFileSizeMax); + /** Sets the maximum size of a single file. An {@link FileSizeLimitExceededException} + * will be thrown, if there is an uploaded file, which is exceeding this value. + * By default, this value will be copied from the {@link FileUploadBase#getFileSizeMax() + * FileUploadBase} object, however, the user may replace the default value with a + * request specific value by invoking {@link #setFileSizeMax(long)} on this object, so + * there is no need to configure it here. + * <em>Note:</em>Changing this value doesn't affect files, that have already been uploaded. + * @param pFileSizeMax The maximum size of a single, uploaded file. The value -1 indicates "unlimited". + */ + void setFileSizeMax(long pFileSizeMax); - /** Returns the maximum size of the complete HTTP request. A {@link SizeLimitExceededException} - * will be thrown, if the HTTP request will exceed this value. - * By default, this value will be copied from the {@link FileUploadBase#getSizeMax() - * FileUploadBase} object, however, the user may replace the default value with a - * request specific value by invoking {@link #setSizeMax(long)} on this object. - * @return The maximum size of the complete HTTP request. The value -1 indicates "unlimited". - */ - long getSizeMax(); + /** Returns the maximum size of the complete HTTP request. A {@link SizeLimitExceededException} + * will be thrown, if the HTTP request will exceed this value. + * By default, this value will be copied from the {@link FileUploadBase#getSizeMax() + * FileUploadBase} object, however, the user may replace the default value with a + * request specific value by invoking {@link #setSizeMax(long)} on this object. + * @return The maximum size of the complete HTTP request. The value -1 indicates "unlimited". + */ + long getSizeMax(); - /** Returns the maximum size of the complete HTTP request. A {@link SizeLimitExceededException} - * will be thrown, if the HTTP request will exceed this value. - * By default, this value will be copied from the {@link FileUploadBase#getSizeMax() - * FileUploadBase} object, however, the user may replace the default value with a - * request specific value by invoking {@link #setSizeMax(long)} on this object. - * <em>Note:</em> Setting the maximum size on this object will work only, if the iterator is not - * yet initialized. In other words: If the methods {@link #hasNext()}, {@link #next()} have not - * yet been invoked. - * @param pSizeMax The maximum size of the complete HTTP request. The value -1 indicates "unlimited". - */ - void setSizeMax(long pSizeMax); + /** Returns the maximum size of the complete HTTP request. A {@link SizeLimitExceededException} + * will be thrown, if the HTTP request will exceed this value. + * By default, this value will be copied from the {@link FileUploadBase#getSizeMax() + * FileUploadBase} object, however, the user may replace the default value with a + * request specific value by invoking {@link #setSizeMax(long)} on this object. + * <em>Note:</em> Setting the maximum size on this object will work only, if the iterator is not + * yet initialized. In other words: If the methods {@link #hasNext()}, {@link #next()} have not + * yet been invoked. + * @param pSizeMax The maximum size of the complete HTTP request. The value -1 indicates "unlimited". + */ + void setSizeMax(long pSizeMax); /** * Returns, whether another instance of {@link FileItemStream} diff --git a/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java b/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java index be258bb..41bd2d3 100644 --- a/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java +++ b/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java @@ -44,32 +44,32 @@ import org.apache.commons.io.IOUtils; * {@link FileUploadBase#getItemIterator(RequestContext)}. */ public class FileItemIteratorImpl implements FileItemIterator { - private final FileUploadBase fileUploadBase; - private final RequestContext ctx; - private long sizeMax, fileSizeMax; + private final FileUploadBase fileUploadBase; + private final RequestContext ctx; + private long sizeMax, fileSizeMax; - @Override - public long getSizeMax() { - return sizeMax; - } + @Override + public long getSizeMax() { + return sizeMax; + } - @Override - public void setSizeMax(final long sizeMax) { - this.sizeMax = sizeMax; - } + @Override + public void setSizeMax(final long sizeMax) { + this.sizeMax = sizeMax; + } - @Override - public long getFileSizeMax() { - return fileSizeMax; - } + @Override + public long getFileSizeMax() { + return fileSizeMax; + } - @Override - public void setFileSizeMax(final long fileSizeMax) { - this.fileSizeMax = fileSizeMax; - } + @Override + public void setFileSizeMax(final long fileSizeMax) { + this.fileSizeMax = fileSizeMax; + } - /** + /** * The multi part stream to process. */ private MultipartStream multiPartStream; @@ -196,10 +196,10 @@ public class FileItemIteratorImpl implements FileItemIterator { } public MultipartStream getMultiPartStream() throws FileUploadException, IOException { - if (multiPartStream == null) { - init(fileUploadBase, ctx); - } - return multiPartStream; + if (multiPartStream == null) { + init(fileUploadBase, ctx); + } + return multiPartStream; } /** @@ -331,15 +331,15 @@ public class FileItemIteratorImpl implements FileItemIterator { return currentItem; } - @Override - public List<FileItem> getFileItems() throws FileUploadException, IOException { - final List<FileItem> items = new ArrayList<>(); - while (hasNext()) { - final FileItemStream fis = next(); - final FileItem fi = fileUploadBase.getFileItemFactory().createItem(fis.getFieldName(), fis.getContentType(), fis.isFormField(), fis.getName()); - items.add(fi); - } - return items; - } + @Override + public List<FileItem> getFileItems() throws FileUploadException, IOException { + final List<FileItem> items = new ArrayList<>(); + while (hasNext()) { + final FileItemStream fis = next(); + final FileItem fi = fileUploadBase.getFileItemFactory().createItem(fis.getFieldName(), fis.getContentType(), fis.isFormField(), fis.getName()); + items.add(fi); + } + return items; + } } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java b/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java index ded94b8..6d2a758 100644 --- a/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java +++ b/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java @@ -35,7 +35,7 @@ import org.apache.commons.fileupload2.util.Streams; * Default implementation of {@link FileItemStream}. */ public class FileItemStreamImpl implements FileItemStream { - private final FileItemIteratorImpl fileItemIteratorImpl; + private final FileItemIteratorImpl fileItemIteratorImpl; /** * The file items content type. @@ -88,7 +88,7 @@ public class FileItemStreamImpl implements FileItemStream { public FileItemStreamImpl(final FileItemIteratorImpl pFileItemIterator, final String pName, final String pFieldName, final String pContentType, final boolean pFormField, final long pContentLength) throws FileUploadException, IOException { - fileItemIteratorImpl = pFileItemIterator; + fileItemIteratorImpl = pFileItemIterator; name = pName; fieldName = pFieldName; contentType = pContentType; diff --git a/src/main/java/org/apache/commons/fileupload2/util/Streams.java b/src/main/java/org/apache/commons/fileupload2/util/Streams.java index 8f7e447..5f40514 100644 --- a/src/main/java/org/apache/commons/fileupload2/util/Streams.java +++ b/src/main/java/org/apache/commons/fileupload2/util/Streams.java @@ -145,7 +145,7 @@ public final class Streams { * @throws IOException An I/O error occurred. */ public static String asString(final InputStream inputStream, final String encoding) - throws IOException { + throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(inputStream, baos, true); return baos.toString(encoding); diff --git a/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java b/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java index 19c753b..ecbec92 100644 --- a/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java +++ b/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java @@ -76,16 +76,16 @@ public class DiskFileUploadTest { public void testMoveFile() throws Exception { final DiskFileUpload myUpload = new DiskFileUpload(); myUpload.setSizeThreshold(0); - final String content = + final String content = "-----1234\r\n" + "Content-Disposition: form-data; name=\"file\";" - + "filename=\"foo.tab\"\r\n" + + + "filename=\"foo.tab\"\r\n" + "Content-Type: text/whatever\r\n" + "\r\n" + "This is the content of the file\n" + "\r\n" + "-----1234--\r\n"; - final byte[] contentBytes = content.getBytes(StandardCharsets.US_ASCII); + final byte[] contentBytes = content.getBytes(StandardCharsets.US_ASCII); final HttpServletRequest request = new MockHttpServletRequest(contentBytes, Constants.CONTENT_TYPE); final List<FileItem> items = myUpload.parseRequest(request); assertNotNull(items); diff --git a/src/test/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUploadTest.java b/src/test/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUploadTest.java index 066652c..f76c2db 100644 --- a/src/test/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUploadTest.java +++ b/src/test/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUploadTest.java @@ -82,7 +82,7 @@ public class JakSrvltFileUploadTest { @Test public void parseImpliedUtf8() - throws Exception { + throws Exception { // utf8 encoded form-data without explicit content-type encoding final String text = "-----1234\r\n" + "Content-Disposition: form-data; name=\"utf8Html\"\r\n" + diff --git a/src/test/java/org/apache/commons/fileupload2/jaksrvlt/MockJakSrvltHttpRequest.java b/src/test/java/org/apache/commons/fileupload2/jaksrvlt/MockJakSrvltHttpRequest.java index 1bf1f05..a4dcc5e 100644 --- a/src/test/java/org/apache/commons/fileupload2/jaksrvlt/MockJakSrvltHttpRequest.java +++ b/src/test/java/org/apache/commons/fileupload2/jaksrvlt/MockJakSrvltHttpRequest.java @@ -567,105 +567,105 @@ public class MockJakSrvltHttpRequest implements HttpServletRequest { return in.read(b, off, len); } - @Override - public boolean isFinished() { - return false; - } - - @Override - public boolean isReady() { - return false; - } - - @Override - public void setReadListener(final ReadListener readListener) { - throw new IllegalStateException("Not implemented"); - } - - } - - @Override - public long getContentLengthLong() { - return (long) getContentLength(); - } - - @Override - public ServletContext getServletContext() { - final HttpSession session = getSession(); - if (session == null) { - return null; - } + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(final ReadListener readListener) { + throw new IllegalStateException("Not implemented"); + } + + } + + @Override + public long getContentLengthLong() { + return (long) getContentLength(); + } + + @Override + public ServletContext getServletContext() { + final HttpSession session = getSession(); + if (session == null) { + return null; + } return session.getServletContext(); - } - - @Override - public AsyncContext startAsync() throws IllegalStateException { - throw new IllegalStateException("Not implemented"); - } - - @Override - public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) - throws IllegalStateException { - throw new IllegalStateException("Not implemented"); - } - - @Override - public boolean isAsyncStarted() { - return false; - } - - @Override - public boolean isAsyncSupported() { - return false; - } - - @Override - public AsyncContext getAsyncContext() { - return null; - } - - @Override - public DispatcherType getDispatcherType() { - return null; - } - - @Override - public String changeSessionId() { - return null; - } - - @Override - public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { - return false; - } - - @Override - public void login(final String username, final String password) throws ServletException { - throw new IllegalStateException("Not implemented"); - } - - @Override - public void logout() throws ServletException { - throw new IllegalStateException("Not implemented"); - } - - @Override - public Collection<Part> getParts() throws IOException, ServletException { - return null; - } - - @Override - public Part getPart(final String name) throws IOException, ServletException { - return null; - } - - @Override - public <T extends HttpUpgradeHandler> T upgrade(final Class<T> handlerClass) throws IOException, ServletException { - throw new IllegalStateException("Not implemented"); - } - - @Override - public String getRealPath(final String path) { - return null; - } + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + throw new IllegalStateException("Not implemented"); + } + + @Override + public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) + throws IllegalStateException { + throw new IllegalStateException("Not implemented"); + } + + @Override + public boolean isAsyncStarted() { + return false; + } + + @Override + public boolean isAsyncSupported() { + return false; + } + + @Override + public AsyncContext getAsyncContext() { + return null; + } + + @Override + public DispatcherType getDispatcherType() { + return null; + } + + @Override + public String changeSessionId() { + return null; + } + + @Override + public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { + return false; + } + + @Override + public void login(final String username, final String password) throws ServletException { + throw new IllegalStateException("Not implemented"); + } + + @Override + public void logout() throws ServletException { + throw new IllegalStateException("Not implemented"); + } + + @Override + public Collection<Part> getParts() throws IOException, ServletException { + return null; + } + + @Override + public Part getPart(final String name) throws IOException, ServletException { + return null; + } + + @Override + public <T extends HttpUpgradeHandler> T upgrade(final Class<T> handlerClass) throws IOException, ServletException { + throw new IllegalStateException("Not implemented"); + } + + @Override + public String getRealPath(final String path) { + return null; + } } diff --git a/src/test/java/org/apache/commons/fileupload2/servlet/ServletFileUploadTest.java b/src/test/java/org/apache/commons/fileupload2/servlet/ServletFileUploadTest.java index ce3675d..769bf13 100644 --- a/src/test/java/org/apache/commons/fileupload2/servlet/ServletFileUploadTest.java +++ b/src/test/java/org/apache/commons/fileupload2/servlet/ServletFileUploadTest.java @@ -83,7 +83,7 @@ public class ServletFileUploadTest { @Test public void parseImpliedUtf8() - throws Exception { + throws Exception { // utf8 encoded form-data without explicit content-type encoding final String text = "-----1234\r\n" + "Content-Disposition: form-data; name=\"utf8Html\"\r\n" +