This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: Account for possible null laddr in Socket.java


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Montag, 16. Juni 2003 15:25 schrieb Mohan Embar:
> Hi (again) Michael,
>
> >>Yes, this part of the code is a problem. Sorry that I have to say
> >> this but I think your patch is half-hearted. raddr can be null
> >> too ...
> >
> >I didn't realize that raddr==null was valid too. Your updated
> > patch looks fine....
>
> I'm reading the J2SE 1.4.0 documentation and don't see anywhere
> that raddr is allowed to be null. In fact, the documentation for
> Socket(InetAddress, int, boolean) seems to imply the contrary
> (cf. "If there is a security manager, its checkConnect method is
> called with host.getHostAddress() and port as its arguments.").
>
> Nor do I see that we are explicitly passing an raddr==null from
> one constructor call to another.
>
> Am I missing something?

Well, I should better explane this.

The currect version is like this:

connect (new InetSocketAddress (raddr, rport));

If raddr is null then InetSocketAddress will assign the wildcard 
address.

connect cannot connect to a wildcard address. IOException.

The ne version is like this:

SocketAddress connectaddr =
  raddr == null ? null : new InetSocketAddress (raddr, rport)
connect (raddr);

Now it connects to null when raddr is null. This makes connect 
throwing IllegalArgumentException. IMO much better.

At least thats the desired behaviour. I dont added a comment about 
this: my fault. Will add the comment.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+7duOWSOgCCdjSDsRAqA9AKCddDgCHBLtI5ddVuIpIbBY1G+l2ACgogQ0
itjUUm2tXqFEYvbgyidVi7Y=
=cKHq
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]