[commons-io] branch master updated: Resue ClosedOutputStream.CLOSED_OUTPUT_STREAM.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new cdbda96  Resue ClosedOutputStream.CLOSED_OUTPUT_STREAM.
cdbda96 is described below

commit cdbda9679f66b4fd5d7fe089240ca6bfd19b1efc
Author: Gary Gregory 
AuthorDate: Mon May 4 11:20:50 2020 -0400

Resue ClosedOutputStream.CLOSED_OUTPUT_STREAM.
---
 src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java 
b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
index 097916b..2212b8f 100644
--- a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
@@ -103,8 +103,7 @@ public class TaggedOutputStreamTest  {
 @Test
 public void testOtherException() throws Exception {
 final IOException exception = new IOException("test exception");
-try (final OutputStream closed = new ClosedOutputStream();
-final TaggedOutputStream stream = new 
TaggedOutputStream(closed)) {
+try (final TaggedOutputStream stream = new 
TaggedOutputStream(ClosedOutputStream.CLOSED_OUTPUT_STREAM)) {
 
 assertFalse(stream.isCauseOf(exception));
 assertFalse(stream.isCauseOf(new TaggedIOException(exception, 
UUID.randomUUID(;



[commons-fileupload] branch master updated: Add the package org.apache.fileupload2.jaksrvlt, for compliance with Jakarta Servlet API 5.0. (See https://github.com/apache/commons-fileupload/pull/25.)

2020-05-04 Thread jochen
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 cd03180  Add the package org.apache.fileupload2.jaksrvlt, for 
compliance with Jakarta Servlet API 5.0. (See 
https://github.com/apache/commons-fileupload/pull/25.)
cd03180 is described below

commit cd031805d2618b0c1dd9c90265ebea1a1ce85387
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 14:07:37 2020 +0200

Add the package org.apache.fileupload2.jaksrvlt,
for compliance with Jakarta Servlet API 5.0.
(See https://github.com/apache/commons-fileupload/pull/25.)
---
 pom.xml|   9 +-
 src/changes/changes.xml|   3 +
 .../fileupload2/jaksrvlt/JakSrvltFileUpload.java   | 153 +
 .../jaksrvlt/JakSrvltRequestContext.java   | 130 
 .../commons/fileupload2/jaksrvlt/package-info.java |  41 ++
 .../apache/commons/fileupload2/util/Streams.java   |   9 +-
 .../jaksrvlt/JakSrvltFileUploadTest.java   | 103 
 .../jaksrvlt/MockJakSrvltHttpRequest.java  | 673 +
 8 files changed, 1116 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 238f9af..af82532 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
   
 org.apache.commons
 commons-parent
-48
+50
   
 
   commons-fileupload2
@@ -250,6 +250,12 @@
   commons-io
   2.2
 
+
+   jakarta.servlet
+   jakarta.servlet-api
+   5.0.0-M1
+   provided
+
   
 
   
@@ -332,6 +338,7 @@
 
   
 
+clean verify apache-rat:check clirr:check 
javadoc:javadoc
   
 
   
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 805c7a6..d9fa59c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The  type attribute can be add,update,fix,remove.
   Bumping 
Compiler Level to 1.8.
   DiskFileItem.write(File) had been changed to use FileUtils.moveFile 
internally, preventing an existing file as the target.
   Performance gains by reusing an internal buffer.
+  Add the package 
org.apache.fileupload2.jaksrvlt,
+for compliance with Jakarta Servlet API 5.0.
+  
 
 
   Don't create 
un-needed resources in FileUploadBase.java
diff --git 
a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java
new file mode 100644
index 000..b5944f9
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2.jaksrvlt;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import jakarta.servlet.http.HttpServletRequest;
+
+import org.apache.commons.fileupload2.FileItem;
+import org.apache.commons.fileupload2.FileItemFactory;
+import org.apache.commons.fileupload2.FileItemIterator;
+import org.apache.commons.fileupload2.FileUpload;
+import org.apache.commons.fileupload2.FileUploadBase;
+import org.apache.commons.fileupload2.FileUploadException;
+
+/**
+ * High level API for processing file uploads.
+ *
+ * This class handles multiple files per single HTML widget, sent using
+ * {@code multipart/mixed} encoding type, as specified by
+ * http://www.ietf.org/rfc/rfc1867.txt;>RFC 1867.  Use {@link
+ * #parseRequest(HttpServletRequest)} to acquire a list of {@link
+ * org.apache.commons.fileupload2.FileItem}s associated with a given HTML
+ * widget.
+ *
+ * How the data for individual parts is stored is determined by the factory
+ * used to create them; a given part may be in memory, on disk, or somewhere
+ * else.
+ */
+public class JakSrvltFileUpload extends FileUpload {
+
+/**
+ * Constant for HTTP POST method.
+ */
+private static final String POST_METHOD = "POST";
+
+// -- Class methods
+
+/**
+ * Utility method that determines whether the request 

[commons-io] branch master updated: Resue org.apache.commons.io.input.ClosedInputStream.CLOSED_INPUT_STREAM.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new c382f5d  Resue 
org.apache.commons.io.input.ClosedInputStream.CLOSED_INPUT_STREAM.
c382f5d is described below

commit c382f5d17a4989ff32bb799d868c0110a780f9aa
Author: Gary Gregory 
AuthorDate: Mon May 4 11:15:15 2020 -0400

Resue org.apache.commons.io.input.ClosedInputStream.CLOSED_INPUT_STREAM.
---
 src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java  | 2 +-
 .../org/apache/commons/io/output/AbstractByteArrayOutputStream.java  | 2 +-
 src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java 
b/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
index e946b54..477dbf2 100644
--- a/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
@@ -62,7 +62,7 @@ public class AutoCloseInputStream extends ProxyInputStream {
 @Override
 public void close() throws IOException {
 in.close();
-in = new ClosedInputStream();
+in = ClosedInputStream.CLOSED_INPUT_STREAM;
 }
 
 /**
diff --git 
a/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java 
b/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
index cf2114b..d350149 100644
--- 
a/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
+++ 
b/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
@@ -307,7 +307,7 @@ public abstract class AbstractByteArrayOutputStream extends 
OutputStream {
 final InputStreamConstructor isConstructor) {
 int remaining = count;
 if (remaining == 0) {
-return new ClosedInputStream();
+return ClosedInputStream.CLOSED_INPUT_STREAM;
 }
 final List list = new ArrayList<>(buffers.size());
 for (final byte[] buf : buffers) {
diff --git 
a/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
index 6e72b5b..91f05fe 100644
--- a/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
@@ -36,7 +36,7 @@ public class TaggedInputStreamTest  {
 
 @Test
 public void testEmptyStream() throws IOException {
-final InputStream stream = new TaggedInputStream(new 
ClosedInputStream());
+final InputStream stream = new 
TaggedInputStream(ClosedInputStream.CLOSED_INPUT_STREAM);
 assertEquals(0, stream.available());
 assertEquals(-1, stream.read());
 assertEquals(-1, stream.read(new byte[1]));
@@ -111,8 +111,7 @@ public class TaggedInputStreamTest  {
 @Test
 public void testOtherException() throws Exception {
 final IOException exception = new IOException("test exception");
-final InputStream closed = new ClosedInputStream();
-final TaggedInputStream stream = new TaggedInputStream(closed);
+final TaggedInputStream stream = new 
TaggedInputStream(ClosedInputStream.CLOSED_INPUT_STREAM);
 
 assertFalse(stream.isCauseOf(exception));
 assertFalse(stream.isCauseOf(



[commons-io] branch master updated: Use try-with-resources.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new 15ef9e9  Use try-with-resources.
15ef9e9 is described below

commit 15ef9e9b0a801ef7d662ef258251a8b857e8081a
Author: Gary Gregory 
AuthorDate: Mon May 4 11:18:13 2020 -0400

Use try-with-resources.
---
 .../apache/commons/io/input/TaggedReaderTest.java  | 45 +++---
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java 
b/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
index a4003f0..d4e97fb 100644
--- a/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
@@ -36,26 +36,26 @@ public class TaggedReaderTest {
 
 @Test
 public void testEmptyReader() throws IOException {
-final Reader reader = new TaggedReader(new ClosedReader());
-assertFalse(reader.ready());
-assertEquals(-1, reader.read());
-assertEquals(-1, reader.read(new char[1]));
-assertEquals(-1, reader.read(new char[1], 0, 1));
-reader.close();
+try (final Reader reader = new 
TaggedReader(ClosedReader.CLOSED_READER)) {
+assertFalse(reader.ready());
+assertEquals(-1, reader.read());
+assertEquals(-1, reader.read(new char[1]));
+assertEquals(-1, reader.read(new char[1], 0, 1));
+}
 }
 
 @Test
 public void testNormalReader() throws IOException {
-final Reader reader = new TaggedReader(new StringReader("abc"));
-assertTrue(reader.ready());
-assertEquals('a', reader.read());
-final char[] buffer = new char[1];
-assertEquals(1, reader.read(buffer));
-assertEquals('b', buffer[0]);
-assertEquals(1, reader.read(buffer, 0, 1));
-assertEquals('c', buffer[0]);
-assertEquals(-1, reader.read());
-reader.close();
+try (final Reader reader = new TaggedReader(new StringReader("abc"))) {
+assertTrue(reader.ready());
+assertEquals('a', reader.read());
+final char[] buffer = new char[1];
+assertEquals(1, reader.read(buffer));
+assertEquals('b', buffer[0]);
+assertEquals(1, reader.read(buffer, 0, 1));
+assertEquals('c', buffer[0]);
+assertEquals(-1, reader.read());
+}
 }
 
 @Test
@@ -109,16 +109,15 @@ public class TaggedReaderTest {
 @Test
 public void testOtherException() throws Exception {
 final IOException exception = new IOException("test exception");
-final Reader closed = new ClosedReader();
-final TaggedReader reader = new TaggedReader(closed);
+try (final TaggedReader reader = new 
TaggedReader(ClosedReader.CLOSED_READER)) {
 
-assertFalse(reader.isCauseOf(exception));
-assertFalse(reader.isCauseOf(new TaggedIOException(exception, 
UUID.randomUUID(;
+assertFalse(reader.isCauseOf(exception));
+assertFalse(reader.isCauseOf(new TaggedIOException(exception, 
UUID.randomUUID(;
 
-reader.throwIfCauseOf(exception);
+reader.throwIfCauseOf(exception);
 
-reader.throwIfCauseOf(new TaggedIOException(exception, 
UUID.randomUUID()));
-reader.close();
+reader.throwIfCauseOf(new TaggedIOException(exception, 
UUID.randomUUID()));
+}
 }
 
 }



[commons-io] branch master updated: Resue ClosedWriter.CLOSED_WRITER.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new c14b996  Resue ClosedWriter.CLOSED_WRITER.
c14b996 is described below

commit c14b996cb61708f9aa66f5ad0ddabed9ef8b672e
Author: Gary Gregory 
AuthorDate: Mon May 4 11:21:59 2020 -0400

Resue ClosedWriter.CLOSED_WRITER.
---
 src/test/java/org/apache/commons/io/output/TaggedWriterTest.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java 
b/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
index 4e5652b..1d2d848 100644
--- a/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
@@ -103,8 +103,7 @@ public class TaggedWriterTest  {
 @Test
 public void testOtherException() throws Exception {
 final IOException exception = new IOException("test exception");
-try (final Writer closed = new ClosedWriter();
-final TaggedWriter writer = new TaggedWriter(closed)) {
+try (final TaggedWriter writer = new 
TaggedWriter(ClosedWriter.CLOSED_WRITER)) {
 
 assertFalse(writer.isCauseOf(exception));
 assertFalse(writer.isCauseOf(new TaggedIOException(exception, 
UUID.randomUUID(;



[commons-io] branch master updated: Javadoc.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new e997b9c  Javadoc.
e997b9c is described below

commit e997b9c670fb1fee2ee0d44759c037c5d5815f6c
Author: Gary Gregory 
AuthorDate: Mon May 4 10:29:31 2020 -0400

Javadoc.
---
 .../commons/io/monitor/FileAlterationMonitor.java  | 23 ++--
 .../commons/io/monitor/FileAlterationObserver.java | 41 +++---
 2 files changed, 33 insertions(+), 31 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java 
b/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
index 17b8cb1..3be7fc6 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
@@ -36,14 +36,14 @@ public final class FileAlterationMonitor implements 
Runnable {
 private volatile boolean running = false;
 
 /**
- * Construct a monitor with a default interval of 10 seconds.
+ * Constructs a monitor with a default interval of 10 seconds.
  */
 public FileAlterationMonitor() {
 this(1);
 }
 
 /**
- * Construct a monitor with the specified interval.
+ * Constructs a monitor with the specified interval.
  *
  * @param interval The amount of time in milliseconds to wait between
  * checks of the file system
@@ -53,7 +53,7 @@ public final class FileAlterationMonitor implements Runnable {
 }
 
 /**
- * Construct a monitor with the specified interval and set of observers.
+ * Constructs a monitor with the specified interval and set of observers.
  *
  * @param interval The amount of time in milliseconds to wait between
  * checks of the file system
@@ -69,7 +69,7 @@ public final class FileAlterationMonitor implements Runnable {
 }
 
 /**
- * Return the interval.
+ * Returns the interval.
  *
  * @return the interval
  */
@@ -78,7 +78,7 @@ public final class FileAlterationMonitor implements Runnable {
 }
 
 /**
- * Set the thread factory.
+ * Sets the thread factory.
  *
  * @param threadFactory the thread factory
  */
@@ -87,7 +87,7 @@ public final class FileAlterationMonitor implements Runnable {
 }
 
 /**
- * Add a file system observer to this monitor.
+ * Adds a file system observer to this monitor.
  *
  * @param observer The file system observer to add
  */
@@ -98,13 +98,14 @@ public final class FileAlterationMonitor implements 
Runnable {
 }
 
 /**
- * Remove a file system observer from this monitor.
+ * Removes a file system observer from this monitor.
  *
  * @param observer The file system observer to remove
  */
 public void removeObserver(final FileAlterationObserver observer) {
 if (observer != null) {
 while (observers.remove(observer)) {
+// empty
 }
 }
 }
@@ -120,7 +121,7 @@ public final class FileAlterationMonitor implements 
Runnable {
 }
 
 /**
- * Start monitoring.
+ * Starts monitoring.
  *
  * @throws Exception if an error occurs initializing the observer
  */
@@ -141,7 +142,7 @@ public final class FileAlterationMonitor implements 
Runnable {
 }
 
 /**
- * Stop monitoring.
+ * Stops monitoring.
  *
  * @throws Exception if an error occurs initializing the observer
  */
@@ -150,7 +151,7 @@ public final class FileAlterationMonitor implements 
Runnable {
 }
 
 /**
- * Stop monitoring.
+ * Stops monitoring.
  *
  * @param stopInterval the amount of time in milliseconds to wait for the 
thread to finish.
  * A value of zero will wait until the thread is finished (see {@link 
Thread#join(long)}).
@@ -174,7 +175,7 @@ public final class FileAlterationMonitor implements 
Runnable {
 }
 
 /**
- * Run.
+ * Runs this monitor.
  */
 @Override
 public void run() {
diff --git 
a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java 
b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
index 9928af8..eff69a1 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
@@ -128,7 +128,7 @@ public class FileAlterationObserver implements Serializable 
{
 private final Comparator comparator;
 
 /**
- * Construct an observer for the specified directory.
+ * Constructs an observer for the specified directory.
  *
  * @param directoryName the name of the directory to observe
  */
@@ -137,7 +137,7 @@ public class FileAlterationObserver implements Serializable 
{
 }
 
 /**
- * 

[commons-fileupload] branch master updated: Adding minimal documentation for the org.apache.commons.fileupload2 package.

2020-05-04 Thread jochen
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 7f5b0d9  Adding minimal documentation for the 
org.apache.commons.fileupload2 package.
7f5b0d9 is described below

commit 7f5b0d9a50b4b929bbec4fbac98b22957a603648
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 21:38:15 2020 +0200

Adding minimal documentation for the org.apache.commons.fileupload2 package.
---
 .../fileupload2/jaksrvlt/JakSrvltFileCleaner.java  |  89 
 src/site/apt/migration.apt.vm  | 116 +
 src/site/site.xml  |  23 ++--
 3 files changed, 217 insertions(+), 11 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
new file mode 100644
index 000..1aeb6a5
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2.jaksrvlt;
+
+
+import org.apache.commons.io.FileCleaningTracker;
+
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletContextEvent;
+import jakarta.servlet.ServletContextListener;
+
+/**
+ * A servlet context listener, which ensures that the
+ * {@link FileCleaningTracker}'s reaper thread is terminated,
+ * when the web application is destroyed.
+ */
+public class JakSrvltFileCleaner implements ServletContextListener {
+
+/**
+ * Attribute name, which is used for storing an instance of
+ * {@link FileCleaningTracker} in the web application.
+ */
+public static final String FILE_CLEANING_TRACKER_ATTRIBUTE
+= JakSrvltFileCleaner.class.getName() + ".FileCleaningTracker";
+
+/**
+ * Returns the instance of {@link FileCleaningTracker}, which is
+ * associated with the given {@link ServletContext}.
+ *
+ * @param pServletContext The servlet context to query
+ * @return The contexts tracker
+ */
+public static FileCleaningTracker
+getFileCleaningTracker(ServletContext pServletContext) {
+return (FileCleaningTracker)
+pServletContext.getAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE);
+}
+
+/**
+ * Sets the instance of {@link FileCleaningTracker}, which is
+ * associated with the given {@link ServletContext}.
+ *
+ * @param pServletContext The servlet context to modify
+ * @param pTracker The tracker to set
+ */
+public static void setFileCleaningTracker(ServletContext pServletContext,
+FileCleaningTracker pTracker) {
+pServletContext.setAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE, 
pTracker);
+}
+
+/**
+ * Called when the web application is initialized. Does
+ * nothing.
+ *
+ * @param sce The servlet context, used for calling
+ *   {@link #setFileCleaningTracker(ServletContext, FileCleaningTracker)}.
+ */
+@Override
+public void contextInitialized(ServletContextEvent sce) {
+setFileCleaningTracker(sce.getServletContext(),
+new FileCleaningTracker());
+}
+
+/**
+ * Called when the web application is being destroyed.
+ * Calls {@link FileCleaningTracker#exitWhenFinished()}.
+ *
+ * @param sce The servlet context, used for calling
+ * {@link #getFileCleaningTracker(ServletContext)}.
+ */
+@Override
+public void contextDestroyed(ServletContextEvent sce) {
+getFileCleaningTracker(sce.getServletContext()).exitWhenFinished();
+}
+}
diff --git a/src/site/apt/migration.apt.vm b/src/site/apt/migration.apt.vm
new file mode 100644
index 000..d443e1f
--- /dev/null
+++ b/src/site/apt/migration.apt.vm
@@ -0,0 +1,116 @@
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements.  See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ 

[commons-fileupload] branch master updated: Updating the using document to reflect the support for Jakarta Servlet API.

2020-05-04 Thread jochen
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 537b7f0  Updating the using document to reflect the support for 
Jakarta Servlet API.
 new c101fc2  Merge branch 'master' of 
https://gitbox.apache.org/repos/asf/commons-fileupload
537b7f0 is described below

commit 537b7f0ba98f08f284d90bdf9be700deb9414414
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 21:38:15 2020 +0200

Updating the using document to reflect the support for Jakarta Servlet API.
---
 .../fileupload2/jaksrvlt/JakSrvltFileCleaner.java  |  89 
 src/site/apt/migration.apt.vm  | 116 +
 src/site/site.xml  |  23 ++--
 src/site/xdoc/using.xml|  24 -
 4 files changed, 240 insertions(+), 12 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
new file mode 100644
index 000..1aeb6a5
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileCleaner.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload2.jaksrvlt;
+
+
+import org.apache.commons.io.FileCleaningTracker;
+
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletContextEvent;
+import jakarta.servlet.ServletContextListener;
+
+/**
+ * A servlet context listener, which ensures that the
+ * {@link FileCleaningTracker}'s reaper thread is terminated,
+ * when the web application is destroyed.
+ */
+public class JakSrvltFileCleaner implements ServletContextListener {
+
+/**
+ * Attribute name, which is used for storing an instance of
+ * {@link FileCleaningTracker} in the web application.
+ */
+public static final String FILE_CLEANING_TRACKER_ATTRIBUTE
+= JakSrvltFileCleaner.class.getName() + ".FileCleaningTracker";
+
+/**
+ * Returns the instance of {@link FileCleaningTracker}, which is
+ * associated with the given {@link ServletContext}.
+ *
+ * @param pServletContext The servlet context to query
+ * @return The contexts tracker
+ */
+public static FileCleaningTracker
+getFileCleaningTracker(ServletContext pServletContext) {
+return (FileCleaningTracker)
+pServletContext.getAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE);
+}
+
+/**
+ * Sets the instance of {@link FileCleaningTracker}, which is
+ * associated with the given {@link ServletContext}.
+ *
+ * @param pServletContext The servlet context to modify
+ * @param pTracker The tracker to set
+ */
+public static void setFileCleaningTracker(ServletContext pServletContext,
+FileCleaningTracker pTracker) {
+pServletContext.setAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE, 
pTracker);
+}
+
+/**
+ * Called when the web application is initialized. Does
+ * nothing.
+ *
+ * @param sce The servlet context, used for calling
+ *   {@link #setFileCleaningTracker(ServletContext, FileCleaningTracker)}.
+ */
+@Override
+public void contextInitialized(ServletContextEvent sce) {
+setFileCleaningTracker(sce.getServletContext(),
+new FileCleaningTracker());
+}
+
+/**
+ * Called when the web application is being destroyed.
+ * Calls {@link FileCleaningTracker#exitWhenFinished()}.
+ *
+ * @param sce The servlet context, used for calling
+ * {@link #getFileCleaningTracker(ServletContext)}.
+ */
+@Override
+public void contextDestroyed(ServletContextEvent sce) {
+getFileCleaningTracker(sce.getServletContext()).exitWhenFinished();
+}
+}
diff --git a/src/site/apt/migration.apt.vm b/src/site/apt/migration.apt.vm
new file mode 100644
index 000..d443e1f
--- /dev/null
+++ b/src/site/apt/migration.apt.vm
@@ -0,0 +1,116 @@
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under 

[commons-fileupload] branch master updated: Minor API simplification by making FileUploadException a subclass of IOException.

2020-05-04 Thread jochen
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 640b1d5  Minor API simplification by making FileUploadException a 
subclass of IOException.
640b1d5 is described below

commit 640b1d53adfeb7271480b4e43ec5bb2fd06e54b0
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 22:03:49 2020 +0200

Minor API simplification by making FileUploadException a subclass of
IOException.
---
 src/main/java/org/apache/commons/fileupload2/FileUploadBase.java  | 4 ++--
 src/main/java/org/apache/commons/fileupload2/FileUploadException.java | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java 
b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
index 76a53ce..deae585 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
@@ -352,8 +352,8 @@ public abstract class FileUploadBase {
 }
 successful = true;
 return items;
-} catch (FileUploadIOException e) {
-throw (FileUploadException) e.getCause();
+} catch (FileUploadException e) {
+throw e;
 } catch (IOException e) {
 throw new FileUploadException(e.getMessage(), e);
 } finally {
diff --git 
a/src/main/java/org/apache/commons/fileupload2/FileUploadException.java 
b/src/main/java/org/apache/commons/fileupload2/FileUploadException.java
index 5e8678c..6301a97 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileUploadException.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileUploadException.java
@@ -16,13 +16,14 @@
  */
 package org.apache.commons.fileupload2;
 
+import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 
 /**
  * Exception for errors encountered while processing the request.
  */
-public class FileUploadException extends Exception {
+public class FileUploadException extends IOException {
 
 /**
  * Serial version UID, being used, if the exception



[commons-fileupload] branch master updated: Documenting a possible incompatibility in a try...catch statement.

2020-05-04 Thread jochen
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 bf4458f  Documenting a possible incompatibility in a try...catch 
statement.
bf4458f is described below

commit bf4458fd37aa9ef6c95e8cdb9964cdf193e47c94
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 22:13:28 2020 +0200

Documenting a possible incompatibility in a try...catch statement.
---
 src/site/apt/migration.apt.vm | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/site/apt/migration.apt.vm b/src/site/apt/migration.apt.vm
index d443e1f..d362496 100644
--- a/src/site/apt/migration.apt.vm
+++ b/src/site/apt/migration.apt.vm
@@ -33,7 +33,7 @@ Migration
2. In your dependency declaration, change the groupId to 
org.apache.commons, the artifactId to
   commons-fileupload2, and the version number to ${project.version}.
 
-   2. Change namespace org.apache.commons.fileupload to 
org.apache.commons.fileupload2.
+   3. Change namespace org.apache.commons.fileupload to 
org.apache.commons.fileupload2.

   Example: Change
 
@@ -47,6 +47,24 @@ Migration
import org.apache.commons.fileupload2.servlet.ServletFileUpload;
 +---
 
+  4. Existing code like the following might give compiler errors, although it
+ looks perfectly valid:
+
++---
+try {
+//  Parse a Fileupload request here.
+} catch (IOException e) {
+// Handle the IOException
+} catch (FileUploadException e) {
+// Handle the FileUploadException
+}
++--- 
+
+With FileUpload 2, this is invalid, because the FileUploadException is now 
a
+subclass of the IOException. The solution is simple: Just switch the order,
+and handle the FileUploadException in the first catch clause, and the 
IOException
+in the second clause.
+
 # Migrating to Jakarta Servlet API, Version 5, or later.
 
   Most existing projects, that are using Commons Fileupload, are based on the 
Java Servlet API, version



[commons-io] branch master updated: Javadoc and normalize param names. Line-lengths to 120.

2020-05-04 Thread ggregory
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
 new ee664f0  Javadoc and normalize param names. Line-lengths to 120.
ee664f0 is described below

commit ee664f09a49428a39bdc4fb9d891cb4e340f7767
Author: Gary Gregory 
AuthorDate: Mon May 4 16:20:38 2020 -0400

Javadoc and normalize param names. Line-lengths to 120.
---
 .../input/MessageDigestCalculatingInputStream.java | 61 --
 .../commons/io/input/ObservableInputStream.java|  3 ++
 2 files changed, 37 insertions(+), 27 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
 
b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
index 6d57dad..ce2b773 100644
--- 
a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
+++ 
b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
@@ -35,24 +35,24 @@ public class MessageDigestCalculatingInputStream extends 
ObservableInputStream {
  * Maintains the message digest.
  */
 public static class MessageDigestMaintainingObserver extends Observer {
-private final MessageDigest md;
+private final MessageDigest messageDigest;
 
 /**
  * Creates an MessageDigestMaintainingObserver for the given 
MessageDigest.
- * @param pMd the message digest to use
+ * @param messageDigest the message digest to use
  */
-public MessageDigestMaintainingObserver(final MessageDigest pMd) {
-md = pMd;
+public MessageDigestMaintainingObserver(final MessageDigest 
messageDigest) {
+this.messageDigest = messageDigest;
 }
 
 @Override
-public void data(final int pByte) throws IOException {
-md.update((byte) pByte);
+public void data(final int input) throws IOException {
+messageDigest.update((byte) input);
 }
 
 @Override
-public void data(final byte[] pBuffer, final int pOffset, final int 
pLength) throws IOException {
-md.update(pBuffer, pOffset, pLength);
+public void data(final byte[] input, final int offset, final int 
length) throws IOException {
+messageDigest.update(input, offset, length);
 }
 }
 
@@ -60,32 +60,39 @@ public class MessageDigestCalculatingInputStream extends 
ObservableInputStream {
 
 /** Creates a new instance, which calculates a signature on the given 
stream,
  * using the given {@link MessageDigest}.
- * @param pStream the stream to calculate the message digest for
- * @param pDigest the message digest to use
+ * @param inputStream the stream to calculate the message digest for
+ * @param MessageDigest the message digest to use
  */
-public MessageDigestCalculatingInputStream(final InputStream pStream, 
final MessageDigest pDigest) {
-super(pStream);
-messageDigest = pDigest;
-add(new MessageDigestMaintainingObserver(pDigest));
+public MessageDigestCalculatingInputStream(final InputStream inputStream, 
final MessageDigest MessageDigest) {
+super(inputStream);
+this.messageDigest = MessageDigest;
+add(new MessageDigestMaintainingObserver(MessageDigest));
 }
 
-/** Creates a new instance, which calculates a signature on the given 
stream,
- * using a {@link MessageDigest} with the given algorithm.
- * @param pStream the stream to calculate the message digest for
- * @param pAlgorithm the name of the algorithm to use
- * @throws NoSuchAlgorithmException if no Provider supports a 
MessageDigestSpi implementation for the specified algorithm.
+/**
+ * Creates a new instance, which calculates a signature on the given 
stream, using a {@link MessageDigest} with the
+ * given algorithm.
+ * 
+ * @param inputStream the stream to calculate the message digest for
+ * @param algorithm the name of the algorithm to use
+ * @throws NoSuchAlgorithmException if no Provider supports a 
MessageDigestSpi implementation for the specified
+ * algorithm.
  */
-public MessageDigestCalculatingInputStream(final InputStream pStream, 
final String pAlgorithm) throws NoSuchAlgorithmException {
-this(pStream, MessageDigest.getInstance(pAlgorithm));
+public MessageDigestCalculatingInputStream(final InputStream inputStream, 
final String algorithm)
+throws NoSuchAlgorithmException {
+this(inputStream, MessageDigest.getInstance(algorithm));
 }
 
-/** Creates a new instance, which calculates a signature on the given 
stream,
- * using a {@link MessageDigest} with the "MD5" algorithm.
- * @param pStream the stream to calculate the message digest for
- * 

[commons-fileupload] branch master updated: Changelog update.

2020-05-04 Thread jochen
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 c27d4d1  Changelog update.
c27d4d1 is described below

commit c27d4d1ecae76e41579b02892a7a0c27da6e34b0
Author: Jochen Wiedmann 
AuthorDate: Mon May 4 22:15:45 2020 +0200

Changelog update.
---
 src/changes/changes.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d9fa59c..1cd5908 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -51,6 +51,8 @@ The  type attribute can be add,update,fix,remove.
   Add the package 
org.apache.fileupload2.jaksrvlt,
 for compliance with Jakarta Servlet API 5.0.
   
+  Making 
FileUploadException a subclass of IOException. (Mibor API simplification.)
+  
 
 
   Don't create 
un-needed resources in FileUploadBase.java