jdk/src/java.base/share/classes/java/io/FilterOutputStream.java
changeset 28292 140e7e529be6
parent 25859 3317bb8137f4
child 31421 d6ddd21f6df8
--- a/jdk/src/java.base/share/classes/java/io/FilterOutputStream.java	Wed Jul 05 20:13:25 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/io/FilterOutputStream.java	Sun Jan 04 19:32:46 2015 +0000
@@ -48,6 +48,8 @@
      */
     protected OutputStream out;
 
+    private boolean closed;
+
     /**
      * Creates an output stream filter built on top of the specified
      * underlying output stream.
@@ -144,9 +146,9 @@
      * Closes this output stream and releases any system resources
      * associated with the stream.
      * <p>
-     * The <code>close</code> method of <code>FilterOutputStream</code>
-     * calls its <code>flush</code> method, and then calls the
-     * <code>close</code> method of its underlying output stream.
+     * When not already closed, the {@code close} method of {@code
+     * FilterOutputStream} calls its {@code flush} method, and then
+     * calls the {@code close} method of its underlying output stream.
      *
      * @exception  IOException  if an I/O error occurs.
      * @see        java.io.FilterOutputStream#flush()
@@ -154,6 +156,9 @@
      */
     @SuppressWarnings("try")
     public void close() throws IOException {
+        if (closed)
+            return;
+        closed = true;
         try (OutputStream ostream = out) {
             flush();
         }