This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: java.net fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Sat, 17 Jul 2004 13:21:07 +0200
- Subject: Patch: java.net fixes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I just commited the attached patch to merge the latest java.net fixes
from classpath to trunk.
Michael
2004-07-17 Jeroen Frijters <jeroen@frijters.net>
* java/net/DatagramPacket.java (setAddress): Removed check for
null address.
2004-07-17 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java
(getLocalAddress): Check if socket is bound or not.
* java/net/Socket.java
(getLocalAddrss): Check if socket is bound or not.
(getPort): Return -1 when not connected. Dont check getImpl() for
null.
(setReuseAddress): Check if socket is closed.
(isConnected): Check if getImpl() returns null.
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFA+QumWSOgCCdjSDsRAubhAJ406WGxVgqnxWGMR/Ip/ZC0qiZrFgCghFRE
RUre680w/CCK4HNCOp6i5Hs=
=Qkhu
-----END PGP SIGNATURE-----
Index: java/net/DatagramPacket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramPacket.java,v
retrieving revision 1.15
diff -u -b -B -r1.15 DatagramPacket.java
--- java/net/DatagramPacket.java 20 Apr 2004 13:05:09 -0000 1.15
+++ java/net/DatagramPacket.java 17 Jul 2004 11:16:22 -0000
@@ -278,9 +278,6 @@
*/
public synchronized void setAddress(InetAddress address)
{
- if (address == null)
- throw new NullPointerException("Null address");
-
this.address = address;
}
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.38
diff -u -b -B -r1.38 DatagramSocket.java
--- java/net/DatagramSocket.java 20 Apr 2004 13:05:09 -0000 1.38
+++ java/net/DatagramSocket.java 17 Jul 2004 11:16:22 -0000
@@ -1,5 +1,6 @@
/* DatagramSocket.java -- A class to model UDP sockets
- Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -282,7 +283,7 @@
*/
public InetAddress getLocalAddress()
{
- if (isClosed())
+ if (! isBound())
return null;
InetAddress localAddr;
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.37
diff -u -b -B -r1.37 Socket.java
--- java/net/Socket.java 22 Apr 2004 06:49:53 -0000 1.37
+++ java/net/Socket.java 17 Jul 2004 11:16:22 -0000
@@ -488,6 +488,9 @@
*/
public InetAddress getLocalAddress()
{
+ if (! isBound())
+ return null;
+
InetAddress addr = null;
try
@@ -523,11 +526,10 @@
public int getPort()
{
if (! isConnected())
- return 0;
+ return -1;
try
{
- if (getImpl() != null)
return getImpl().getPort();
}
catch (SocketException e)
@@ -1155,6 +1157,9 @@
*/
public void setReuseAddress(boolean reuseAddress) throws SocketException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
getImpl().setOption(SocketOptions.SO_REUSEADDR,
Boolean.valueOf(reuseAddress));
}
@@ -1217,6 +1222,9 @@
{
try
{
+ if (getImpl() == null)
+ return false;
+
return getImpl().getInetAddress() != null;
}
catch (SocketException e)