This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
PATCH: close method in java.net and java.io
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: PATCH: close method in java.net and java.io
- From: Warren Levy <warrenl at cygnus dot com>
- Date: Fri, 8 Dec 2000 02:27:18 -0800 (PST)
Folks,
I've done a bit of cleanup based on the Mauve java.io and java.net
results. The close method previously could allow exceptions to be thrown
inadvertantly.
--warrenl
2000-12-08 Warren Levy <warrenl@redhat.com>
* 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.
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/FileInputStream.java,v
retrieving revision 1.4
diff -u -p -r1.4 FileInputStream.java
--- FileInputStream.java 2000/03/07 19:55:26 1.4
+++ FileInputStream.java 2000/12/08 10:20:55
@@ -51,11 +51,8 @@ public class FileInputStream extends Inp
public void close() throws IOException
{
- if (fd == null)
- return;
-
- fd.close();
- fd = null;
+ if (fd.valid())
+ fd.close();
}
protected void finalize() throws IOException
Index: java/io/RandomAccessFile.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/RandomAccessFile.java,v
retrieving revision 1.4
diff -u -p -r1.4 RandomAccessFile.java
--- RandomAccessFile.java 2000/03/07 19:55:26 1.4
+++ RandomAccessFile.java 2000/12/08 10:20:55
@@ -24,7 +24,8 @@ public class RandomAccessFile implements
{
public void close () throws IOException
{
- fd.close();
+ if (fd.valid())
+ fd.close();
}
public final FileDescriptor getFD () throws IOException
Index: java/net/PlainDatagramSocketImpl.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/PlainDatagramSocketImpl.java,v
retrieving revision 1.8
diff -u -p -r1.8 PlainDatagramSocketImpl.java
--- PlainDatagramSocketImpl.java 2000/03/07 19:55:27 1.8
+++ PlainDatagramSocketImpl.java 2000/12/08 10:20:55
@@ -79,7 +79,8 @@ class PlainDatagramSocketImpl extends Da
// we'll catch the IOException here.
try
{
- fd.close();
+ if (fd.valid())
+ fd.close();
}
catch (IOException e)
{
Index: java/net/PlainSocketImpl.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/PlainSocketImpl.java,v
retrieving revision 1.7
diff -u -p -r1.7 PlainSocketImpl.java
--- PlainSocketImpl.java 2000/03/07 19:55:27 1.7
+++ PlainSocketImpl.java 2000/12/08 10:20:55
@@ -92,6 +92,7 @@ class PlainSocketImpl extends SocketImpl
protected void close () throws IOException
{
- fd.close();
+ if (fd.valid())
+ fd.close();
}
}