This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: Account for possible null laddr in Socket.java
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: Michael Koch <konqueror at gmx dot de>
- Cc: GCJ Patches <java-patches at gcc dot gnu dot org>
- Date: Mon, 16 Jun 2003 23:10:45 -0500
- Subject: Re: Patch: Account for possible null laddr in Socket.java
- Reply-to: gnustuff at thisiscool dot com
Hi Michael,
>> 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.
No, if raddr is null then a NullPointerException gets thrown
in the InetSocketAddress constructor via addr.getHostName()
>The new 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.
Now I understand. This seems consistent with the JavaDoc, though
a comment <i>would</i> help :)
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/