Skip to content

Commit 4d3a6bb

Browse files
author
Gary Gregory
committed
Un-derpecate IOUtils.closeQuietly() methods.
1 parent 876c18a commit 4d3a6bb

2 files changed

Lines changed: 33 additions & 38 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ The <action> type attribute can be add,update,fix,remove.
5757
<action dev="ggregory" type="fix" due-to="Michael Ernst, Gary Gregory">
5858
Make `FilenameUtils.equals()` not throw an exception #154.
5959
</action>
60+
<action dev="ggregory" type="fix" due-to="Jan Peter Stotz, Bernd Eckenfels, Gary Gregory">
61+
Un-derpecate IOUtils.closeQuietly() methods.
62+
</action>
6063
<!-- ADD -->
6164
<action dev="ggregory" type="add" due-to="Gary Gregory">
6265
Add FileSystemProviders class.

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public class IOUtils {
135135

136136
/**
137137
* The system line separator string.
138-
*
138+
*
139139
* @deprecated Use {@link System#lineSeparator()}.
140140
*/
141141
@Deprecated
@@ -155,7 +155,7 @@ public class IOUtils {
155155
* The default buffer to use for the skip() methods.
156156
*/
157157
private static final byte[] SKIP_BYTE_BUFFER = new byte[DEFAULT_BUFFER_SIZE];
158-
158+
159159
// Allocated in the relevant skip method if necessary.
160160
/*
161161
* These buffers are static and are shared between threads.
@@ -359,6 +359,7 @@ public static void close(final URLConnection conn) {
359359

360360
/**
361361
* Closes a <code>Closeable</code> unconditionally.
362+
*
362363
* <p>
363364
* Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is typically used in
364365
* finally blocks.
@@ -388,15 +389,15 @@ public static void close(final URLConnection conn) {
388389
* IOUtils.closeQuietly(outputStream);
389390
* }
390391
* </pre>
392+
* <p>
393+
* Also consider using a try-with-resources statement where appropriate.
394+
* </p>
391395
*
392396
* @param closeable the objects to close, may be null or already closed
393397
* @since 2.0
394398
*
395-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
396-
* suppressed exceptions manually.
397399
* @see Throwable#addSuppressed(java.lang.Throwable)
398400
*/
399-
@Deprecated
400401
public static void closeQuietly(final Closeable closeable) {
401402
closeQuietly(closeable, (Consumer<IOException>) null);
402403
}
@@ -439,16 +440,14 @@ public static void closeQuietly(final Closeable closeable) {
439440
* IOUtils.closeQuietly(inputStream, outputStream);
440441
* }
441442
* </pre>
442-
*
443+
* <p>
444+
* Also consider using a try-with-resources statement where appropriate.
445+
* </p>
443446
* @param closeables the objects to close, may be null or already closed
444447
* @see #closeQuietly(Closeable)
445448
* @since 2.5
446-
*
447-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
448-
* suppressed exceptions manually.
449449
* @see Throwable#addSuppressed(java.lang.Throwable)
450450
*/
451-
@Deprecated
452451
public static void closeQuietly(final Closeable... closeables) {
453452
if (closeables == null) {
454453
return;
@@ -497,14 +496,13 @@ public static void closeQuietly(final Closeable closeable, final Consumer<IOExce
497496
* IOUtils.closeQuietly(in);
498497
* }
499498
* </pre>
499+
* <p>
500+
* Also consider using a try-with-resources statement where appropriate.
501+
* </p>
500502
*
501503
* @param input the InputStream to close, may be null or already closed
502-
*
503-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
504-
* suppressed exceptions manually.
505504
* @see Throwable#addSuppressed(java.lang.Throwable)
506505
*/
507-
@Deprecated
508506
public static void closeQuietly(final InputStream input) {
509507
closeQuietly((Closeable) input);
510508
}
@@ -530,14 +528,13 @@ public static void closeQuietly(final InputStream input) {
530528
* IOUtils.closeQuietly(out);
531529
* }
532530
* </pre>
531+
* <p>
532+
* Also consider using a try-with-resources statement where appropriate.
533+
* </p>
533534
*
534535
* @param output the OutputStream to close, may be null or already closed
535-
*
536-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
537-
* suppressed exceptions manually.
538536
* @see Throwable#addSuppressed(java.lang.Throwable)
539537
*/
540-
@Deprecated
541538
public static void closeQuietly(final OutputStream output) {
542539
closeQuietly((Closeable) output);
543540
}
@@ -562,14 +559,13 @@ public static void closeQuietly(final OutputStream output) {
562559
* IOUtils.closeQuietly(in);
563560
* }
564561
* </pre>
562+
* <p>
563+
* Also consider using a try-with-resources statement where appropriate.
564+
* </p>
565565
*
566566
* @param input the Reader to close, may be null or already closed
567-
*
568-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
569-
* suppressed exceptions manually.
570567
* @see Throwable#addSuppressed(java.lang.Throwable)
571568
*/
572-
@Deprecated
573569
public static void closeQuietly(final Reader input) {
574570
closeQuietly((Closeable) input);
575571
}
@@ -593,15 +589,14 @@ public static void closeQuietly(final Reader input) {
593589
* IOUtils.closeQuietly(selector);
594590
* }
595591
* </pre>
592+
* <p>
593+
* Also consider using a try-with-resources statement where appropriate.
594+
* </p>
596595
*
597596
* @param selector the Selector to close, may be null or already closed
598597
* @since 2.2
599-
*
600-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
601-
* suppressed exceptions manually.
602598
* @see Throwable#addSuppressed(java.lang.Throwable)
603599
*/
604-
@Deprecated
605600
public static void closeQuietly(final Selector selector) {
606601
closeQuietly((Closeable) selector);
607602
}
@@ -625,15 +620,14 @@ public static void closeQuietly(final Selector selector) {
625620
* IOUtils.closeQuietly(socket);
626621
* }
627622
* </pre>
623+
* <p>
624+
* Also consider using a try-with-resources statement where appropriate.
625+
* </p>
628626
*
629627
* @param serverSocket the ServerSocket to close, may be null or already closed
630628
* @since 2.2
631-
*
632-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
633-
* suppressed exceptions manually.
634629
* @see Throwable#addSuppressed(java.lang.Throwable)
635630
*/
636-
@Deprecated
637631
public static void closeQuietly(final ServerSocket serverSocket) {
638632
closeQuietly((Closeable) serverSocket);
639633
}
@@ -657,15 +651,14 @@ public static void closeQuietly(final ServerSocket serverSocket) {
657651
* IOUtils.closeQuietly(socket);
658652
* }
659653
* </pre>
654+
* <p>
655+
* Also consider using a try-with-resources statement where appropriate.
656+
* </p>
660657
*
661658
* @param socket the Socket to close, may be null or already closed
662659
* @since 2.0
663-
*
664-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
665-
* suppressed exceptions manually.
666660
* @see Throwable#addSuppressed(java.lang.Throwable)
667661
*/
668-
@Deprecated
669662
public static void closeQuietly(final Socket socket) {
670663
closeQuietly((Closeable) socket);
671664
}
@@ -689,14 +682,13 @@ public static void closeQuietly(final Socket socket) {
689682
* IOUtils.closeQuietly(out);
690683
* }
691684
* </pre>
685+
* <p>
686+
* Also consider using a try-with-resources statement where appropriate.
687+
* </p>
692688
*
693689
* @param output the Writer to close, may be null or already closed
694-
*
695-
* @deprecated As of 2.6 deprecated without replacement. Please use the try-with-resources statement or handle
696-
* suppressed exceptions manually.
697690
* @see Throwable#addSuppressed(java.lang.Throwable)
698691
*/
699-
@Deprecated
700692
public static void closeQuietly(final Writer output) {
701693
closeQuietly((Closeable) output);
702694
}

0 commit comments

Comments
 (0)