@@ -331,38 +331,46 @@ public static void closeQuietly(final Closeable closeable) {
331331 /**
332332 * Closes a <code>Closeable</code> unconditionally.
333333 * <p>
334- * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is typically used in
335- * finally blocks.
334+ * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored.
335+ * <p>
336+ * This is typically used in finally blocks to ensure that the closeable is closed
337+ * even if an Exception was thrown before the normal close statement was reached.
338+ * <br>
339+ * <b>It should not be used to replace the close statement(s)
340+ * which should be present for the non-exceptional case.</b>
341+ * <br>
342+ * It is only intended to simplify tidying up where normal processing has already failed
343+ * and reporting close failure as well is not necessary or useful.
336344 * <p>
337345 * Example code:
338346 *
339347 * <pre>
340348 * Closeable closeable = null;
341349 * try {
342350 * closeable = new FileReader("foo.txt");
343- * // process closeable
344- * closeable.close();
351+ * // processing using the closeable; may throw an Exception
352+ * closeable.close(); // Normal close - exceptions not ignored
345353 * } catch (Exception e) {
346354 * // error handling
347355 * } finally {
348- * IOUtils.closeQuietly(closeable);
356+ * <b> IOUtils.closeQuietly(closeable); // In case normal close was skipped due to Exception</b>
349357 * }
350358 * </pre>
351359 *
352360 * Closing all streams:
353- *
361+ * <br>TODO - fix this example, it is wrong; ought not to ignore Exceptions here
354362 * <pre>
355363 * try {
356364 * return IOUtils.copy(inputStream, outputStream);
357365 * } finally {
358- * IOUtils.closeQuietly(inputStream);
359- * IOUtils.closeQuietly(outputStream);
366+ * IOUtils.closeQuietly(inputStream, outputStream);
360367 * }
361368 * </pre>
362369 *
363370 * @param closeables
364371 * the objects to close, may be null or already closed
365372 * @since 2.5
373+ * @see #closeQuietly(Closeable)
366374 */
367375 public static void closeQuietly (final Closeable ... closeables ) {
368376 if (closeables == null ) {
0 commit comments