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 4d3a6bb Un-derpecate IOUtils.closeQuietly() methods.
4d3a6bb is described below
commit 4d3a6bb54f7d0867cd6f279ce3778719688eb1ec
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Oct 8 14:30:54 2020 -0400
Un-derpecate IOUtils.closeQuietly() methods.
---
src/changes/changes.xml | 3 ++
src/main/java/org/apache/commons/io/IOUtils.java | 68 +++++++++++-------------
2 files changed, 33 insertions(+), 38 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e4e3a50..ff46a89 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -57,6 +57,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="fix" due-to="Michael Ernst, Gary Gregory">
Make `FilenameUtils.equals()` not throw an exception #154.
</action>
+ <action dev="ggregory" type="fix" due-to="Jan Peter Stotz, Bernd
Eckenfels, Gary Gregory">
+ Un-derpecate IOUtils.closeQuietly() methods.
+ </action>
<!-- ADD -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add FileSystemProviders class.
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java
b/src/main/java/org/apache/commons/io/IOUtils.java
index 9bfe142..4deb206 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -135,7 +135,7 @@ public class IOUtils {
/**
* The system line separator string.
- *
+ *
* @deprecated Use {@link System#lineSeparator()}.
*/
@Deprecated
@@ -155,7 +155,7 @@ public class IOUtils {
* The default buffer to use for the skip() methods.
*/
private static final byte[] SKIP_BYTE_BUFFER = new
byte[DEFAULT_BUFFER_SIZE];
-
+
// Allocated in the relevant skip method if necessary.
/*
* These buffers are static and are shared between threads.
@@ -359,6 +359,7 @@ public class IOUtils {
/**
* Closes a <code>Closeable</code> unconditionally.
+ *
* <p>
* Equivalent to {@link Closeable#close()}, except any exceptions will be
ignored. This is typically used in
* finally blocks.
@@ -388,15 +389,15 @@ public class IOUtils {
* IOUtils.closeQuietly(outputStream);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param closeable the objects to close, may be null or already closed
* @since 2.0
*
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Closeable closeable) {
closeQuietly(closeable, (Consumer<IOException>) null);
}
@@ -439,16 +440,14 @@ public class IOUtils {
* IOUtils.closeQuietly(inputStream, outputStream);
* }
* </pre>
- *
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
* @param closeables the objects to close, may be null or already closed
* @see #closeQuietly(Closeable)
* @since 2.5
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Closeable... closeables) {
if (closeables == null) {
return;
@@ -497,14 +496,13 @@ public class IOUtils {
* IOUtils.closeQuietly(in);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param input the InputStream to close, may be null or already closed
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final InputStream input) {
closeQuietly((Closeable) input);
}
@@ -530,14 +528,13 @@ public class IOUtils {
* IOUtils.closeQuietly(out);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param output the OutputStream to close, may be null or already closed
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final OutputStream output) {
closeQuietly((Closeable) output);
}
@@ -562,14 +559,13 @@ public class IOUtils {
* IOUtils.closeQuietly(in);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param input the Reader to close, may be null or already closed
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Reader input) {
closeQuietly((Closeable) input);
}
@@ -593,15 +589,14 @@ public class IOUtils {
* IOUtils.closeQuietly(selector);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param selector the Selector to close, may be null or already closed
* @since 2.2
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Selector selector) {
closeQuietly((Closeable) selector);
}
@@ -625,15 +620,14 @@ public class IOUtils {
* IOUtils.closeQuietly(socket);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param serverSocket the ServerSocket to close, may be null or already
closed
* @since 2.2
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final ServerSocket serverSocket) {
closeQuietly((Closeable) serverSocket);
}
@@ -657,15 +651,14 @@ public class IOUtils {
* IOUtils.closeQuietly(socket);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param socket the Socket to close, may be null or already closed
* @since 2.0
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Socket socket) {
closeQuietly((Closeable) socket);
}
@@ -689,14 +682,13 @@ public class IOUtils {
* IOUtils.closeQuietly(out);
* }
* </pre>
+ * <p>
+ * Also consider using a try-with-resources statement where appropriate.
+ * </p>
*
* @param output the Writer to close, may be null or already closed
- *
- * @deprecated As of 2.6 deprecated without replacement. Please use the
try-with-resources statement or handle
- * suppressed exceptions manually.
* @see Throwable#addSuppressed(java.lang.Throwable)
*/
- @Deprecated
public static void closeQuietly(final Writer output) {
closeQuietly((Closeable) output);
}