changeset 3810:bac152c6491a

7021327: Changes for 7020888 included changes to other files in error Reviewed-by: chegar
author alanb
date Tue, 22 Feb 2011 14:28:13 +0000
parents 9d8a0369b906
children b853414b8eef
files src/share/classes/java/io/BufferedReader.java src/share/classes/java/io/BufferedWriter.java src/share/classes/java/io/FilterOutputStream.java src/share/classes/java/io/PushbackInputStream.java src/share/classes/java/io/PushbackReader.java test/java/lang/ProcessBuilder/Basic.java
diffstat 6 files changed, 28 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/io/BufferedReader.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/src/share/classes/java/io/BufferedReader.java	Tue Feb 22 14:28:13 2011 +0000
@@ -512,14 +512,11 @@
 
     public void close() throws IOException {
         synchronized (lock) {
-            if (in != null) {
-                try {
-                    in.close();
-                } finally {
-                    in = null;
-                    cb = null;
-                }
-            }
+            if (in == null)
+                return;
+            in.close();
+            in = null;
+            cb = null;
         }
     }
 }
--- a/src/share/classes/java/io/BufferedWriter.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/src/share/classes/java/io/BufferedWriter.java	Tue Feb 22 14:28:13 2011 +0000
@@ -255,16 +255,17 @@
         }
     }
 
-    @SuppressWarnings("try")
     public void close() throws IOException {
         synchronized (lock) {
-            if (out != null) {
-                try (Writer w = out) {
-                    flushBuffer();
-                } finally {
-                    out = null;
-                    cb = null;
-                }
+            if (out == null) {
+                return;
+            }
+            try {
+                flushBuffer();
+            } finally {
+                out.close();
+                out = null;
+                cb = null;
             }
         }
     }
--- a/src/share/classes/java/io/FilterOutputStream.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/src/share/classes/java/io/FilterOutputStream.java	Tue Feb 22 14:28:13 2011 +0000
@@ -152,10 +152,11 @@
      * @see        java.io.FilterOutputStream#flush()
      * @see        java.io.FilterOutputStream#out
      */
-    @SuppressWarnings("try")
     public void close() throws IOException {
-        try (OutputStream ostream = out) {
-            flush();
+        try {
+          flush();
+        } catch (IOException ignored) {
         }
+        out.close();
     }
 }
--- a/src/share/classes/java/io/PushbackInputStream.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/src/share/classes/java/io/PushbackInputStream.java	Tue Feb 22 14:28:13 2011 +0000
@@ -374,13 +374,10 @@
      * @exception  IOException  if an I/O error occurs.
      */
     public synchronized void close() throws IOException {
-        if (in != null) {
-            try {
-                in.close();
-            } finally {
-                in = null;
-                buf = null;
-            }
-        }
+        if (in == null)
+            return;
+        in.close();
+        in = null;
+        buf = null;
     }
 }
--- a/src/share/classes/java/io/PushbackReader.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/src/share/classes/java/io/PushbackReader.java	Tue Feb 22 14:28:13 2011 +0000
@@ -245,11 +245,8 @@
      * @exception  IOException  If an I/O error occurs
      */
     public void close() throws IOException {
-        try {
-            super.close();
-        } finally {
-            buf = null;
-        }
+        super.close();
+        buf = null;
     }
 
     /**
--- a/test/java/lang/ProcessBuilder/Basic.java	Tue Feb 22 12:04:48 2011 +0000
+++ b/test/java/lang/ProcessBuilder/Basic.java	Tue Feb 22 14:28:13 2011 +0000
@@ -1762,9 +1762,9 @@
 
             equal(p.exitValue(), 5);
 
-            try { p.getInputStream().close(); } catch (IOException ignore) { }
-            try  {p.getErrorStream().close(); } catch (IOException ignore) { }
-            try { p.getOutputStream().close(); } catch (IOException ignore) { }
+            p.getInputStream().close();
+            p.getErrorStream().close();
+            p.getOutputStream().close();
 
             InputStream[] streams = { p.getInputStream(), p.getErrorStream() };
             for (final InputStream in : streams) {