< prev index next >

src/java.base/share/classes/java/io/SequenceInputStream.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -218,10 +218,23 @@
      * before the <code>close</code> method returns.
      *
      * @exception  IOException  if an I/O error occurs.
      */
     public void close() throws IOException {
-        do {
-            nextStream();
-        } while (in != null);
+        IOException ioe = null;
+        while (in != null) {
+            try {
+                in.close();
+            } catch (IOException e) {
+                if (ioe == null) {
+                    ioe = e;
+                } else {
+                    ioe.addSuppressed(e);
+                }
+            }
+            peekNextStream();
+        }
+        if (ioe != null) {
+            throw ioe;
+        }
     }
 }
< prev index next >