You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Andrew Zhang <zh...@gmail.com> on 2006/06/22 09:42:21 UTC
Bug to bug compatibility: SocketChannel.socket().getLocalPort() returns 0 while Harmony returns -1
Hi everybody,
I found a bug of SocketChannel.socket() of RI.
Consider following test case:
public void test_socket() throws IOException {
SocketChannel sc = SocketChannel.open();
Socket socket = sc.socket();
assertFalse(socket.isBound());
// RI returns 0 instead of -1 here.
assertEquals(-1, socket.getLocalPort());
}
RI 1.5 fails while Harmony passes.
"returns the local port number to which this socket is bound or -1 if the
socket is not bound yet." That's how spec describes getLocalPort method.
RI returns 0 for an unbound socket, violates spec apparently.
How shall we deal with this bug to bug compatibility?
Any suggestions? Thank you very much!
--
Andrew Zhang
China Software Development Lab, IBM
Re: Bug to bug compatibility: SocketChannel.socket().getLocalPort()
returns 0 while Harmony returns -1
Posted by Tim Ellison <t....@gmail.com>.
I agree, it should return -1 as per spec.
Regards,
Tim
Mikhail Loenko wrote:
> Then I believe we should go spec
>
> Thanks,
> Mikhail
>
> 2006/6/22, Andrew Zhang <zh...@gmail.com>:
>> Hi Mikhail,
>>
>> So far as I know, only the socket obtained from SocketChannel returns 0
>> instead of -1.
>>
>> If the socket is constructed directly, it returns -1 as spec says.
>> Following
>> test passes against RI without any problem.
>>
>> public void test_socket() throws IOException {
>> Socket s = new Socket();
>> assertFalse(s.isBound());
>> assertEquals(-1, s.getLocalPort());
>> }
>>
>> Thanks!
>>
>> On 6/22/06, Mikhail Loenko <ml...@gmail.com> wrote:
>> >
>> > Hi Andrew,
>> >
>> > have you noticed, does RI return 0 for any unbound socket or
>> > only for the sockets obtained from SocketChannel?
>> >
>> > Thanks,
>> > Mikhail
>> >
>> > 2006/6/22, Andrew Zhang <zh...@gmail.com>:
>> > > Hi everybody,
>> > >
>> > > I found a bug of SocketChannel.socket() of RI.
>> > >
>> > > Consider following test case:
>> > >
>> > > public void test_socket() throws IOException {
>> > > SocketChannel sc = SocketChannel.open();
>> > > Socket socket = sc.socket();
>> > > assertFalse(socket.isBound());
>> > > // RI returns 0 instead of -1 here.
>> > > assertEquals(-1, socket.getLocalPort());
>> > > }
>> > >
>> > > RI 1.5 fails while Harmony passes.
>> > >
>> > > "returns the local port number to which this socket is bound or -1 if
>> > the
>> > > socket is not bound yet." That's how spec describes getLocalPort
>> method.
>> > >
>> > > RI returns 0 for an unbound socket, violates spec apparently.
>> > >
>> > > How shall we deal with this bug to bug compatibility?
>> > >
>> > > Any suggestions? Thank you very much!
>> > >
>> > >
>> > > --
>> > > Andrew Zhang
>> > > China Software Development Lab, IBM
>> > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> --
>> Andrew Zhang
>> China Software Development Lab, IBM
>>
>>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>
--
Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org
Re: Bug to bug compatibility: SocketChannel.socket().getLocalPort() returns 0 while Harmony returns -1
Posted by Mikhail Loenko <ml...@gmail.com>.
Then I believe we should go spec
Thanks,
Mikhail
2006/6/22, Andrew Zhang <zh...@gmail.com>:
> Hi Mikhail,
>
> So far as I know, only the socket obtained from SocketChannel returns 0
> instead of -1.
>
> If the socket is constructed directly, it returns -1 as spec says. Following
> test passes against RI without any problem.
>
> public void test_socket() throws IOException {
> Socket s = new Socket();
> assertFalse(s.isBound());
> assertEquals(-1, s.getLocalPort());
> }
>
> Thanks!
>
> On 6/22/06, Mikhail Loenko <ml...@gmail.com> wrote:
> >
> > Hi Andrew,
> >
> > have you noticed, does RI return 0 for any unbound socket or
> > only for the sockets obtained from SocketChannel?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/6/22, Andrew Zhang <zh...@gmail.com>:
> > > Hi everybody,
> > >
> > > I found a bug of SocketChannel.socket() of RI.
> > >
> > > Consider following test case:
> > >
> > > public void test_socket() throws IOException {
> > > SocketChannel sc = SocketChannel.open();
> > > Socket socket = sc.socket();
> > > assertFalse(socket.isBound());
> > > // RI returns 0 instead of -1 here.
> > > assertEquals(-1, socket.getLocalPort());
> > > }
> > >
> > > RI 1.5 fails while Harmony passes.
> > >
> > > "returns the local port number to which this socket is bound or -1 if
> > the
> > > socket is not bound yet." That's how spec describes getLocalPort method.
> > >
> > > RI returns 0 for an unbound socket, violates spec apparently.
> > >
> > > How shall we deal with this bug to bug compatibility?
> > >
> > > Any suggestions? Thank you very much!
> > >
> > >
> > > --
> > > Andrew Zhang
> > > China Software Development Lab, IBM
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org
Re: Bug to bug compatibility: SocketChannel.socket().getLocalPort() returns 0 while Harmony returns -1
Posted by Andrew Zhang <zh...@gmail.com>.
Hi Mikhail,
So far as I know, only the socket obtained from SocketChannel returns 0
instead of -1.
If the socket is constructed directly, it returns -1 as spec says. Following
test passes against RI without any problem.
public void test_socket() throws IOException {
Socket s = new Socket();
assertFalse(s.isBound());
assertEquals(-1, s.getLocalPort());
}
Thanks!
On 6/22/06, Mikhail Loenko <ml...@gmail.com> wrote:
>
> Hi Andrew,
>
> have you noticed, does RI return 0 for any unbound socket or
> only for the sockets obtained from SocketChannel?
>
> Thanks,
> Mikhail
>
> 2006/6/22, Andrew Zhang <zh...@gmail.com>:
> > Hi everybody,
> >
> > I found a bug of SocketChannel.socket() of RI.
> >
> > Consider following test case:
> >
> > public void test_socket() throws IOException {
> > SocketChannel sc = SocketChannel.open();
> > Socket socket = sc.socket();
> > assertFalse(socket.isBound());
> > // RI returns 0 instead of -1 here.
> > assertEquals(-1, socket.getLocalPort());
> > }
> >
> > RI 1.5 fails while Harmony passes.
> >
> > "returns the local port number to which this socket is bound or -1 if
> the
> > socket is not bound yet." That's how spec describes getLocalPort method.
> >
> > RI returns 0 for an unbound socket, violates spec apparently.
> >
> > How shall we deal with this bug to bug compatibility?
> >
> > Any suggestions? Thank you very much!
> >
> >
> > --
> > Andrew Zhang
> > China Software Development Lab, IBM
> >
> >
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>
--
Andrew Zhang
China Software Development Lab, IBM
Re: Bug to bug compatibility: SocketChannel.socket().getLocalPort() returns 0 while Harmony returns -1
Posted by Mikhail Loenko <ml...@gmail.com>.
Hi Andrew,
have you noticed, does RI return 0 for any unbound socket or
only for the sockets obtained from SocketChannel?
Thanks,
Mikhail
2006/6/22, Andrew Zhang <zh...@gmail.com>:
> Hi everybody,
>
> I found a bug of SocketChannel.socket() of RI.
>
> Consider following test case:
>
> public void test_socket() throws IOException {
> SocketChannel sc = SocketChannel.open();
> Socket socket = sc.socket();
> assertFalse(socket.isBound());
> // RI returns 0 instead of -1 here.
> assertEquals(-1, socket.getLocalPort());
> }
>
> RI 1.5 fails while Harmony passes.
>
> "returns the local port number to which this socket is bound or -1 if the
> socket is not bound yet." That's how spec describes getLocalPort method.
>
> RI returns 0 for an unbound socket, violates spec apparently.
>
> How shall we deal with this bug to bug compatibility?
>
> Any suggestions? Thank you very much!
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org
Re: Bug to bug compatibility: SocketChannel.socket().getLocalPort()
returns 0 while Harmony returns -1
Posted by Paulex Yang <pa...@gmail.com>.
Andrew,
How the current Harmony codes looks like?
According to our compatibility guideline[1], we should stick to Spec if
it is clearly stated.
[1]
http://incubator.apache.org/harmony/subcomponents/classlibrary/compat.html
Andrew Zhang wrote:
> Hi everybody,
>
> I found a bug of SocketChannel.socket() of RI.
>
> Consider following test case:
>
> public void test_socket() throws IOException {
> SocketChannel sc = SocketChannel.open();
> Socket socket = sc.socket();
> assertFalse(socket.isBound());
> // RI returns 0 instead of -1 here.
> assertEquals(-1, socket.getLocalPort());
> }
>
> RI 1.5 fails while Harmony passes.
>
> "returns the local port number to which this socket is bound or -1 if the
> socket is not bound yet." That's how spec describes getLocalPort method.
>
> RI returns 0 for an unbound socket, violates spec apparently.
>
> How shall we deal with this bug to bug compatibility?
>
> Any suggestions? Thank you very much!
>
>
--
Paulex Yang
China Software Development Lab
IBM
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org