From be17b0fcff12cbe0e14ef171ba970c8c751c3694 Mon Sep 17 00:00:00 2001 From: Warren Levy Date: Fri, 8 Dec 2000 10:28:32 +0000 Subject: [PATCH] FileInputStream.java (close): Check if the fd is valid. * java/io/FileInputStream.java (close): Check if the fd is valid. * java/io/RandomAccessFile.java (close): Ditto. * java/net/PlainDatagramSocketImpl.java (close): Ditto. * java/net/PlainSocketImpl.java (close): Ditto. From-SVN: r38131 --- libjava/ChangeLog | 7 +++++++ libjava/java/io/FileInputStream.java | 7 ++----- libjava/java/io/RandomAccessFile.java | 3 ++- libjava/java/net/PlainDatagramSocketImpl.java | 3 ++- libjava/java/net/PlainSocketImpl.java | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 0a95dd50bf9..91f20e77135 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2000-12-08 Warren Levy + + * java/io/FileInputStream.java (close): Check if the fd is valid. + * java/io/RandomAccessFile.java (close): Ditto. + * java/net/PlainDatagramSocketImpl.java (close): Ditto. + * java/net/PlainSocketImpl.java (close): Ditto. + 2000-12-06 Tom Tromey * java/awt/GridBagConstraints.java: Filled in values for static diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java index e5071e40e89..67d4842f4f8 100644 --- a/libjava/java/io/FileInputStream.java +++ b/libjava/java/io/FileInputStream.java @@ -51,11 +51,8 @@ public class FileInputStream extends InputStream public void close() throws IOException { - if (fd == null) - return; - - fd.close(); - fd = null; + if (fd.valid()) + fd.close(); } protected void finalize() throws IOException diff --git a/libjava/java/io/RandomAccessFile.java b/libjava/java/io/RandomAccessFile.java index d054afc2033..9a0bf807202 100644 --- a/libjava/java/io/RandomAccessFile.java +++ b/libjava/java/io/RandomAccessFile.java @@ -24,7 +24,8 @@ public class RandomAccessFile implements DataOutput, DataInput { public void close () throws IOException { - fd.close(); + if (fd.valid()) + fd.close(); } public final FileDescriptor getFD () throws IOException diff --git a/libjava/java/net/PlainDatagramSocketImpl.java b/libjava/java/net/PlainDatagramSocketImpl.java index 9a290dcd0f8..7076ccf31b1 100644 --- a/libjava/java/net/PlainDatagramSocketImpl.java +++ b/libjava/java/net/PlainDatagramSocketImpl.java @@ -79,7 +79,8 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl // we'll catch the IOException here. try { - fd.close(); + if (fd.valid()) + fd.close(); } catch (IOException e) { diff --git a/libjava/java/net/PlainSocketImpl.java b/libjava/java/net/PlainSocketImpl.java index df9d4387d44..49155d942b7 100644 --- a/libjava/java/net/PlainSocketImpl.java +++ b/libjava/java/net/PlainSocketImpl.java @@ -92,6 +92,7 @@ class PlainSocketImpl extends SocketImpl protected void close () throws IOException { - fd.close(); + if (fd.valid()) + fd.close(); } }