From 585dba004b3ee66a9ada968bbd0cb790aceb9e1c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 9 Jan 2010 18:22:16 -0700 Subject: [PATCH] ignore redundant calls to File{In|Out}putStream.close Previously, we threw an IOException, which did not match Sun's behavior. --- classpath/java/io/FileInputStream.java | 6 ++++-- classpath/java/io/FileOutputStream.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/classpath/java/io/FileInputStream.java b/classpath/java/io/FileInputStream.java index 1c7a6c9532..4c0d576368 100644 --- a/classpath/java/io/FileInputStream.java +++ b/classpath/java/io/FileInputStream.java @@ -55,7 +55,9 @@ public class FileInputStream extends InputStream { } public void close() throws IOException { - close(fd); - fd = -1; + if (fd != -1) { + close(fd); + fd = -1; + } } } diff --git a/classpath/java/io/FileOutputStream.java b/classpath/java/io/FileOutputStream.java index 4d50412414..d61d44e136 100644 --- a/classpath/java/io/FileOutputStream.java +++ b/classpath/java/io/FileOutputStream.java @@ -55,7 +55,9 @@ public class FileOutputStream extends OutputStream { } public void close() throws IOException { - close(fd); - fd = -1; + if (fd != -1) { + close(fd); + fd = -1; + } } }