提交 5f1f5d2c 编写于 作者: A alanb

7021327: Changes for 7020888 included changes to other files in error

Reviewed-by: chegar
上级 57de7398
...@@ -512,14 +512,11 @@ public class BufferedReader extends Reader { ...@@ -512,14 +512,11 @@ public class BufferedReader extends Reader {
public void close() throws IOException { public void close() throws IOException {
synchronized (lock) { synchronized (lock) {
if (in != null) { if (in == null)
try { return;
in.close(); in.close();
} finally { in = null;
in = null; cb = null;
cb = null;
}
}
} }
} }
} }
...@@ -255,16 +255,17 @@ public class BufferedWriter extends Writer { ...@@ -255,16 +255,17 @@ public class BufferedWriter extends Writer {
} }
} }
@SuppressWarnings("try")
public void close() throws IOException { public void close() throws IOException {
synchronized (lock) { synchronized (lock) {
if (out != null) { if (out == null) {
try (Writer w = out) { return;
flushBuffer(); }
} finally { try {
out = null; flushBuffer();
cb = null; } finally {
} out.close();
out = null;
cb = null;
} }
} }
} }
......
...@@ -152,10 +152,11 @@ class FilterOutputStream extends OutputStream { ...@@ -152,10 +152,11 @@ class FilterOutputStream extends OutputStream {
* @see java.io.FilterOutputStream#flush() * @see java.io.FilterOutputStream#flush()
* @see java.io.FilterOutputStream#out * @see java.io.FilterOutputStream#out
*/ */
@SuppressWarnings("try")
public void close() throws IOException { public void close() throws IOException {
try (OutputStream ostream = out) { try {
flush(); flush();
} catch (IOException ignored) {
} }
out.close();
} }
} }
...@@ -374,13 +374,10 @@ class PushbackInputStream extends FilterInputStream { ...@@ -374,13 +374,10 @@ class PushbackInputStream extends FilterInputStream {
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
public synchronized void close() throws IOException { public synchronized void close() throws IOException {
if (in != null) { if (in == null)
try { return;
in.close(); in.close();
} finally { in = null;
in = null; buf = null;
buf = null;
}
}
} }
} }
...@@ -245,11 +245,8 @@ public class PushbackReader extends FilterReader { ...@@ -245,11 +245,8 @@ public class PushbackReader extends FilterReader {
* @exception IOException If an I/O error occurs * @exception IOException If an I/O error occurs
*/ */
public void close() throws IOException { public void close() throws IOException {
try { super.close();
super.close(); buf = null;
} finally {
buf = null;
}
} }
/** /**
......
...@@ -1762,9 +1762,9 @@ public class Basic { ...@@ -1762,9 +1762,9 @@ public class Basic {
equal(p.exitValue(), 5); equal(p.exitValue(), 5);
try { p.getInputStream().close(); } catch (IOException ignore) { } p.getInputStream().close();
try {p.getErrorStream().close(); } catch (IOException ignore) { } p.getErrorStream().close();
try { p.getOutputStream().close(); } catch (IOException ignore) { } p.getOutputStream().close();
InputStream[] streams = { p.getInputStream(), p.getErrorStream() }; InputStream[] streams = { p.getInputStream(), p.getErrorStream() };
for (final InputStream in : streams) { for (final InputStream in : streams) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册