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/09/14 04:02:42 UTC

Re: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Would any commiter like to confirm and close this "non-bug differences from
RI" jira? Thanks!

On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
>
> From: Andrew Zhang (JIRA) <ji...@apache.org>
> Date: Sep 13, 2006 11:02 AM
> Subject: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility:
> java.net.URL new URL("ss", null, -3, null) throws MalformedURLException
> while RI throws NPE
> To: harmony-commits@incubator.apache.org
>
>    [
> http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348]
>
> Andrew Zhang commented on HARMONY-1158:
> ---------------------------------------
>
> Ilya, I agree with you. Spec has explicitly pointed out "No validation of
> the inputs is performed by this constructor."
>
> The tests show that the exception thrown sequence is uncertain and
> implemention-dependent.
>
> If no application and test cases are broken by currenty Harmony code, I
> suggest not fix the problem.
>
> Best regards,
> Andrew
>
> > [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3,
> null) throws MalformedURLException while RI throws NPE
> >
> --------------------------------------------------------------------------------------------------------------------------
> >
> >                 Key: HARMONY-1158
> >                 URL: http://issues.apache.org/jira/browse/HARMONY-1158
> >             Project: Harmony
> >          Issue Type: Bug
> >          Components: Non-bug differences from RI
> >            Reporter: Ilya Okomin
> >
> > Compatibility. Different order of exceptions.
> > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> constructor if host ==null while Harmony at first checks port and throws
> MalformedURLException.
> > If host != null both RI and Harmony throw MalformedURLException.
> > =============test.java=============
> > import java.net.*;
> > public class test  {
> >     public static void main (String[] args) {
> >        try {
> >             new URL("ss", "0", -3, null);
> >        } catch (Exception e) {
> >            e.printStackTrace();
> >        }
> >        try {
> >             new URL("ss", null, -3, null);
> >        } catch (Exception e) {
> >            e.printStackTrace();
> >        }
> >     }
> > }
> > =======================================
> > Output on RI:
> > java.net.MalformedURLException : Invalid port number :-3
> >         at java.net.URL.<init>(URL.java:373)
> >         at java.net.URL.<init>(URL.java:283)
> >         at test.main(test.java:7)
> > java.lang.NullPointerException
> >         at java.net.Parts.<init>(URL.java:1259)
> >         at java.net.URL.<init>(URL.java:380)
> >         at java.net.URL.<init>(URL.java:283)
> >         at test.main(test.java:13)
> > Output on Harmony:
> > java.net.MalformedURLException: Port out of range: -3
> >         at java.net.URL.<init>(URL.java:393)
> >         at java.net.URL.<init>(URL.java:367)
> >         at test.main(test.java:7)
> > java.net.MalformedURLException: Port out of range: -3
> >         at java.net.URL.<init>(URL.java:393)
> >         at java.net.URL.<init>(URL.java:367)
>
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
> http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>



-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Alexey Petrenko <al...@gmail.com>.
I have not said that it validaites. I said that it can :)

2006/9/14, Stepan Mishura <st...@gmail.com>:
> On 9/14/06, Alexey Petrenko wrote:
> >
> > 2006/9/14, Stepan Mishura :
> > > On 9/14/06, Alexey Petrenko wrote:
> > > >
> > > > 2006/9/14, Stepan Mishura :
> > > > > On 9/14/06, Andrew Zhang wrote:
> > > > > >
> > > > > > There are two reasons:
> > > > > >
> > > > > > 1. Spec has explicitly pointed out "No validation of the inputs is
> > > > > > performed
> > > > > > by this constructor."
> > > > >
> > > > >
> > > > >
> > > > > In this spec. quotation above there is one thing that confuses me -
> > > > "THIS
> > > > > CONSTRUCTOR". May this mean that validation of inputs is perform,
> > for
> > > > > example, only by corresponding protocol handler?
> > > > >
> > > > > This looks logical because only protocol handler can verify whether
> > > > params
> > > > > are correct or not.
> > > > Almost right. But if RI passes all the parameters to protocol handler
> > > > then it should throw unknown protocol for all these cases. Since "ss"
> > > > is unknown protocol.
> > > > And you do not need a protocol handler to understand that port number
> > > > can not have a negative value :)
> > > Not agree. What if I add a custom protocol handler that accepts negative
> > > port values?
> > It will break RFC 2396 (Uniform Resource Identifiers (URI): Generic
> > Syntax) [1] where port is specified as "port = *digit". And this is
> > unsigned value.
>
>
>
> Then the spec. is not quite correct - the constructor validates some inputs
> :-)
>
> -Stepan
>
> <SNIP>
>
> ------------------------------------------------------
> 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
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Stepan Mishura <st...@gmail.com>.
On 9/14/06, Alexey Petrenko wrote:
>
> 2006/9/14, Stepan Mishura :
> > On 9/14/06, Alexey Petrenko wrote:
> > >
> > > 2006/9/14, Stepan Mishura :
> > > > On 9/14/06, Andrew Zhang wrote:
> > > > >
> > > > > There are two reasons:
> > > > >
> > > > > 1. Spec has explicitly pointed out "No validation of the inputs is
> > > > > performed
> > > > > by this constructor."
> > > >
> > > >
> > > >
> > > > In this spec. quotation above there is one thing that confuses me -
> > > "THIS
> > > > CONSTRUCTOR". May this mean that validation of inputs is perform,
> for
> > > > example, only by corresponding protocol handler?
> > > >
> > > > This looks logical because only protocol handler can verify whether
> > > params
> > > > are correct or not.
> > > Almost right. But if RI passes all the parameters to protocol handler
> > > then it should throw unknown protocol for all these cases. Since "ss"
> > > is unknown protocol.
> > > And you do not need a protocol handler to understand that port number
> > > can not have a negative value :)
> > Not agree. What if I add a custom protocol handler that accepts negative
> > port values?
> It will break RFC 2396 (Uniform Resource Identifiers (URI): Generic
> Syntax) [1] where port is specified as "port = *digit". And this is
> unsigned value.



Then the spec. is not quite correct - the constructor validates some inputs
:-)

-Stepan

<SNIP>

------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Alexey Petrenko <al...@gmail.com>.
2006/9/14, Stepan Mishura <st...@gmail.com>:
> On 9/14/06, Alexey Petrenko wrote:
> >
> > 2006/9/14, Stepan Mishura :
> > > On 9/14/06, Andrew Zhang wrote:
> > > >
> > > > There are two reasons:
> > > >
> > > > 1. Spec has explicitly pointed out "No validation of the inputs is
> > > > performed
> > > > by this constructor."
> > >
> > >
> > >
> > > In this spec. quotation above there is one thing that confuses me -
> > "THIS
> > > CONSTRUCTOR". May this mean that validation of inputs is perform, for
> > > example, only by corresponding protocol handler?
> > >
> > > This looks logical because only protocol handler can verify whether
> > params
> > > are correct or not.
> > Almost right. But if RI passes all the parameters to protocol handler
> > then it should throw unknown protocol for all these cases. Since "ss"
> > is unknown protocol.
> > And you do not need a protocol handler to understand that port number
> > can not have a negative value :)
> Not agree. What if I add a custom protocol handler that accepts negative
> port values?
It will break RFC 2396 (Uniform Resource Identifiers (URI): Generic
Syntax) [1] where port is specified as "port = *digit". And this is
unsigned value.

SY, Alexey

[1] http://www.ietf.org/rfc/rfc2396.txt

> Thanks,
> Stepan.
>
>
> > SY, Alexey
> >
> > >
> > > Thanks,
> > > Stepan.
> > >
> > > 2. The exception thrown sequence is really hard to follow, as described
> > by
> > > > Ilya, see examples below:
> > > >
> > > > 1. new URL("ss", "0", -3, null);
> > > > java.net.MalformedURLException: Invalid port number :-3
> > > >
> > > > 2. new URL("ss", null, -3, null);
> > > > java.lang.NullPointerException
> > > >
> > > > 3. new URL("ss", "0", -3, "file");
> > > > java.net.MalformedURLException: Invalid port number :-3
> > > >
> > > > 4. new URL("ss", null, -3, "file");
> > > > java.net.MalformedURLException: unknown protocol: ss
> > > >
> > > > 5. new URL("ss", "0", -1, null);
> > > > java.lang.NullPointerException
> > > >
> > > > Yes, we should follow RI for exception thrown sequence if possible.
> > But
> > > > for
> > > > thise case, would anyone suggest how to throw exception to follow RI?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> > > > >
> > > > > It's not clear why it should be non-bug diff?
> > > > >
> > > > > Shouldn't it be fixed to follow RI?
> > > > >
> > > > > Thanks,
> > > > > Mikhail
> > > > >
> > > > > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > > > > Would any commiter like to confirm and close this "non-bug
> > differences
> > > > > from
> > > > > > RI" jira? Thanks!
> > > > > >
> > > > > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > > > > >
> > > > > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > > > > Date: Sep 13, 2006 11:02 AM
> > > > > > > Subject: [jira] Commented: (HARMONY-1158)
> > > > > [classlib][luni]Compatibility:
> > > > > > > java.net.URL new URL("ss", null, -3, null) throws
> > > > > MalformedURLException
> > > > > > > while RI throws NPE
> > > > > > > To: harmony-commits@incubator.apache.org
> > > > > > >
> > > > > > >    [
> > > > > > >
> > > > >
> > > >
> > http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > > > > ]
> > > > > > >
> > > > > > > Andrew Zhang commented on HARMONY-1158:
> > > > > > > ---------------------------------------
> > > > > > >
> > > > > > > Ilya, I agree with you. Spec has explicitly pointed out "No
> > > > validation
> > > > > of
> > > > > > > the inputs is performed by this constructor."
> > > > > > >
> > > > > > > The tests show that the exception thrown sequence is uncertain
> > and
> > > > > > > implemention-dependent.
> > > > > > >
> > > > > > > If no application and test cases are broken by currenty Harmony
> > > > code,
> > > > > I
> > > > > > > suggest not fix the problem.
> > > > > > >
> > > > > > > Best regards,
> > > > > > > Andrew
> > > > > > >
> > > > > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss",
> > null,
> > > > -3,
> > > > > > > null) throws MalformedURLException while RI throws NPE
> > > > > > > >
> > > > > > >
> > > > >
> > > >
> > --------------------------------------------------------------------------------------------------------------------------
> > > > > > > >
> > > > > > > >                 Key: HARMONY-1158
> > > > > > > >                 URL:
> > > > > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > > > > >             Project: Harmony
> > > > > > > >          Issue Type: Bug
> > > > > > > >          Components: Non-bug differences from RI
> > > > > > > >            Reporter: Ilya Okomin
> > > > > > > >
> > > > > > > > Compatibility. Different order of exceptions.
> > > > > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3,
> > null)
> > > > > > > constructor if host ==null while Harmony at first checks port
> > and
> > > > > throws
> > > > > > > MalformedURLException.
> > > > > > > > If host != null both RI and Harmony throw
> > MalformedURLException.
> > > > > > > > =============test.java=============
> > > > > > > > import java.net.*;
> > > > > > > > public class test  {
> > > > > > > >     public static void main (String[] args) {
> > > > > > > >        try {
> > > > > > > >             new URL("ss", "0", -3, null);
> > > > > > > >        } catch (Exception e) {
> > > > > > > >            e.printStackTrace();
> > > > > > > >        }
> > > > > > > >        try {
> > > > > > > >             new URL("ss", null, -3, null);
> > > > > > > >        } catch (Exception e) {
> > > > > > > >            e.printStackTrace();
> > > > > > > >        }
> > > > > > > >     }
> > > > > > > > }
> > > > > > > > =======================================
> > > > > > > > Output on RI:
> > > > > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > > > > >         at java.net.URL.<init>(URL.java:373)
> > > > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > > > >         at test.main(test.java:7)
> > > > > > > > java.lang.NullPointerException
> > > > > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > > > > >         at java.net.URL.<init>(URL.java:380)
> > > > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > > > >         at test.main(test.java:13)
> > > > > > > > Output on Harmony:
> > > > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > > > >         at test.main(test.java:7)
> > > > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > > >
> > > > > > > --
> > > > > > > This message is automatically generated by JIRA.
> > > > > > > -
> > > > > > > If you think it was sent incorrectly contact one of the
> > > > > administrators:
> > > > > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > > > > -
> > > > > > > For more information on JIRA, see:
> > > > > http://www.atlassian.com/software/jira
> >
> >
>
>
> --
> Thanks,
> Stepan Mishura
> Intel Middleware Products Division
>
> ------------------------------------------------------
> 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
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Stepan Mishura <st...@gmail.com>.
On 9/14/06, Alexey Petrenko wrote:
>
> 2006/9/14, Stepan Mishura :
> > On 9/14/06, Andrew Zhang wrote:
> > >
> > > There are two reasons:
> > >
> > > 1. Spec has explicitly pointed out "No validation of the inputs is
> > > performed
> > > by this constructor."
> >
> >
> >
> > In this spec. quotation above there is one thing that confuses me -
> "THIS
> > CONSTRUCTOR". May this mean that validation of inputs is perform, for
> > example, only by corresponding protocol handler?
> >
> > This looks logical because only protocol handler can verify whether
> params
> > are correct or not.
> Almost right. But if RI passes all the parameters to protocol handler
> then it should throw unknown protocol for all these cases. Since "ss"
> is unknown protocol.
> And you do not need a protocol handler to understand that port number
> can not have a negative value :)



Not agree. What if I add a custom protocol handler that accepts negative
port values?

Thanks,
Stepan.


> SY, Alexey
>
> >
> > Thanks,
> > Stepan.
> >
> > 2. The exception thrown sequence is really hard to follow, as described
> by
> > > Ilya, see examples below:
> > >
> > > 1. new URL("ss", "0", -3, null);
> > > java.net.MalformedURLException: Invalid port number :-3
> > >
> > > 2. new URL("ss", null, -3, null);
> > > java.lang.NullPointerException
> > >
> > > 3. new URL("ss", "0", -3, "file");
> > > java.net.MalformedURLException: Invalid port number :-3
> > >
> > > 4. new URL("ss", null, -3, "file");
> > > java.net.MalformedURLException: unknown protocol: ss
> > >
> > > 5. new URL("ss", "0", -1, null);
> > > java.lang.NullPointerException
> > >
> > > Yes, we should follow RI for exception thrown sequence if possible.
> But
> > > for
> > > thise case, would anyone suggest how to throw exception to follow RI?
> > >
> > >
> > >
> > >
> > >
> > > On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> > > >
> > > > It's not clear why it should be non-bug diff?
> > > >
> > > > Shouldn't it be fixed to follow RI?
> > > >
> > > > Thanks,
> > > > Mikhail
> > > >
> > > > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > > > Would any commiter like to confirm and close this "non-bug
> differences
> > > > from
> > > > > RI" jira? Thanks!
> > > > >
> > > > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > > > >
> > > > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > > > Date: Sep 13, 2006 11:02 AM
> > > > > > Subject: [jira] Commented: (HARMONY-1158)
> > > > [classlib][luni]Compatibility:
> > > > > > java.net.URL new URL("ss", null, -3, null) throws
> > > > MalformedURLException
> > > > > > while RI throws NPE
> > > > > > To: harmony-commits@incubator.apache.org
> > > > > >
> > > > > >    [
> > > > > >
> > > >
> > >
> http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > > > ]
> > > > > >
> > > > > > Andrew Zhang commented on HARMONY-1158:
> > > > > > ---------------------------------------
> > > > > >
> > > > > > Ilya, I agree with you. Spec has explicitly pointed out "No
> > > validation
> > > > of
> > > > > > the inputs is performed by this constructor."
> > > > > >
> > > > > > The tests show that the exception thrown sequence is uncertain
> and
> > > > > > implemention-dependent.
> > > > > >
> > > > > > If no application and test cases are broken by currenty Harmony
> > > code,
> > > > I
> > > > > > suggest not fix the problem.
> > > > > >
> > > > > > Best regards,
> > > > > > Andrew
> > > > > >
> > > > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss",
> null,
> > > -3,
> > > > > > null) throws MalformedURLException while RI throws NPE
> > > > > > >
> > > > > >
> > > >
> > >
> --------------------------------------------------------------------------------------------------------------------------
> > > > > > >
> > > > > > >                 Key: HARMONY-1158
> > > > > > >                 URL:
> > > > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > > > >             Project: Harmony
> > > > > > >          Issue Type: Bug
> > > > > > >          Components: Non-bug differences from RI
> > > > > > >            Reporter: Ilya Okomin
> > > > > > >
> > > > > > > Compatibility. Different order of exceptions.
> > > > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3,
> null)
> > > > > > constructor if host ==null while Harmony at first checks port
> and
> > > > throws
> > > > > > MalformedURLException.
> > > > > > > If host != null both RI and Harmony throw
> MalformedURLException.
> > > > > > > =============test.java=============
> > > > > > > import java.net.*;
> > > > > > > public class test  {
> > > > > > >     public static void main (String[] args) {
> > > > > > >        try {
> > > > > > >             new URL("ss", "0", -3, null);
> > > > > > >        } catch (Exception e) {
> > > > > > >            e.printStackTrace();
> > > > > > >        }
> > > > > > >        try {
> > > > > > >             new URL("ss", null, -3, null);
> > > > > > >        } catch (Exception e) {
> > > > > > >            e.printStackTrace();
> > > > > > >        }
> > > > > > >     }
> > > > > > > }
> > > > > > > =======================================
> > > > > > > Output on RI:
> > > > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > > > >         at java.net.URL.<init>(URL.java:373)
> > > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > > >         at test.main(test.java:7)
> > > > > > > java.lang.NullPointerException
> > > > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > > > >         at java.net.URL.<init>(URL.java:380)
> > > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > > >         at test.main(test.java:13)
> > > > > > > Output on Harmony:
> > > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > > >         at test.main(test.java:7)
> > > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > >
> > > > > > --
> > > > > > This message is automatically generated by JIRA.
> > > > > > -
> > > > > > If you think it was sent incorrectly contact one of the
> > > > administrators:
> > > > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > > > -
> > > > > > For more information on JIRA, see:
> > > > http://www.atlassian.com/software/jira
>
>


-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Alexey Petrenko <al...@gmail.com>.
2006/9/14, Stepan Mishura <st...@gmail.com>:
> On 9/14/06, Andrew Zhang wrote:
> >
> > There are two reasons:
> >
> > 1. Spec has explicitly pointed out "No validation of the inputs is
> > performed
> > by this constructor."
>
>
>
> In this spec. quotation above there is one thing that confuses me - "THIS
> CONSTRUCTOR". May this mean that validation of inputs is perform, for
> example, only by corresponding protocol handler?
>
> This looks logical because only protocol handler can verify whether params
> are correct or not.
Almost right. But if RI passes all the parameters to protocol handler
then it should throw unknown protocol for all these cases. Since "ss"
is unknown protocol.
And you do not need a protocol handler to understand that port number
can not have a negative value :)

SY, Alexey

>
> Thanks,
> Stepan.
>
> 2. The exception thrown sequence is really hard to follow, as described by
> > Ilya, see examples below:
> >
> > 1. new URL("ss", "0", -3, null);
> > java.net.MalformedURLException: Invalid port number :-3
> >
> > 2. new URL("ss", null, -3, null);
> > java.lang.NullPointerException
> >
> > 3. new URL("ss", "0", -3, "file");
> > java.net.MalformedURLException: Invalid port number :-3
> >
> > 4. new URL("ss", null, -3, "file");
> > java.net.MalformedURLException: unknown protocol: ss
> >
> > 5. new URL("ss", "0", -1, null);
> > java.lang.NullPointerException
> >
> > Yes, we should follow RI for exception thrown sequence if possible. But
> > for
> > thise case, would anyone suggest how to throw exception to follow RI?
> >
> >
> >
> >
> >
> > On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> > >
> > > It's not clear why it should be non-bug diff?
> > >
> > > Shouldn't it be fixed to follow RI?
> > >
> > > Thanks,
> > > Mikhail
> > >
> > > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > > Would any commiter like to confirm and close this "non-bug differences
> > > from
> > > > RI" jira? Thanks!
> > > >
> > > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > > >
> > > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > > Date: Sep 13, 2006 11:02 AM
> > > > > Subject: [jira] Commented: (HARMONY-1158)
> > > [classlib][luni]Compatibility:
> > > > > java.net.URL new URL("ss", null, -3, null) throws
> > > MalformedURLException
> > > > > while RI throws NPE
> > > > > To: harmony-commits@incubator.apache.org
> > > > >
> > > > >    [
> > > > >
> > >
> > http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > > ]
> > > > >
> > > > > Andrew Zhang commented on HARMONY-1158:
> > > > > ---------------------------------------
> > > > >
> > > > > Ilya, I agree with you. Spec has explicitly pointed out "No
> > validation
> > > of
> > > > > the inputs is performed by this constructor."
> > > > >
> > > > > The tests show that the exception thrown sequence is uncertain and
> > > > > implemention-dependent.
> > > > >
> > > > > If no application and test cases are broken by currenty Harmony
> > code,
> > > I
> > > > > suggest not fix the problem.
> > > > >
> > > > > Best regards,
> > > > > Andrew
> > > > >
> > > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null,
> > -3,
> > > > > null) throws MalformedURLException while RI throws NPE
> > > > > >
> > > > >
> > >
> > --------------------------------------------------------------------------------------------------------------------------
> > > > > >
> > > > > >                 Key: HARMONY-1158
> > > > > >                 URL:
> > > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > > >             Project: Harmony
> > > > > >          Issue Type: Bug
> > > > > >          Components: Non-bug differences from RI
> > > > > >            Reporter: Ilya Okomin
> > > > > >
> > > > > > Compatibility. Different order of exceptions.
> > > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > > > constructor if host ==null while Harmony at first checks port and
> > > throws
> > > > > MalformedURLException.
> > > > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > > > =============test.java=============
> > > > > > import java.net.*;
> > > > > > public class test  {
> > > > > >     public static void main (String[] args) {
> > > > > >        try {
> > > > > >             new URL("ss", "0", -3, null);
> > > > > >        } catch (Exception e) {
> > > > > >            e.printStackTrace();
> > > > > >        }
> > > > > >        try {
> > > > > >             new URL("ss", null, -3, null);
> > > > > >        } catch (Exception e) {
> > > > > >            e.printStackTrace();
> > > > > >        }
> > > > > >     }
> > > > > > }
> > > > > > =======================================
> > > > > > Output on RI:
> > > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > > >         at java.net.URL.<init>(URL.java:373)
> > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > >         at test.main(test.java:7)
> > > > > > java.lang.NullPointerException
> > > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > > >         at java.net.URL.<init>(URL.java:380)
> > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > >         at test.main(test.java:13)
> > > > > > Output on Harmony:
> > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > >         at test.main(test.java:7)
> > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > >
> > > > > --
> > > > > This message is automatically generated by JIRA.
> > > > > -
> > > > > If you think it was sent incorrectly contact one of the
> > > administrators:
> > > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > > -
> > > > > For more information on JIRA, see:
> > > http://www.atlassian.com/software/jira
> >
> >
>
> --
> Thanks,
> Stepan Mishura
> Intel Middleware Products Division
>
> ------------------------------------------------------
> 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
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Stepan Mishura <st...@gmail.com>.
On 9/14/06, Andrew Zhang wrote:
>
> There are two reasons:
>
> 1. Spec has explicitly pointed out "No validation of the inputs is
> performed
> by this constructor."



In this spec. quotation above there is one thing that confuses me - "THIS
CONSTRUCTOR". May this mean that validation of inputs is perform, for
example, only by corresponding protocol handler?

This looks logical because only protocol handler can verify whether params
are correct or not.

Thanks,
Stepan.

2. The exception thrown sequence is really hard to follow, as described by
> Ilya, see examples below:
>
> 1. new URL("ss", "0", -3, null);
> java.net.MalformedURLException: Invalid port number :-3
>
> 2. new URL("ss", null, -3, null);
> java.lang.NullPointerException
>
> 3. new URL("ss", "0", -3, "file");
> java.net.MalformedURLException: Invalid port number :-3
>
> 4. new URL("ss", null, -3, "file");
> java.net.MalformedURLException: unknown protocol: ss
>
> 5. new URL("ss", "0", -1, null);
> java.lang.NullPointerException
>
> Yes, we should follow RI for exception thrown sequence if possible. But
> for
> thise case, would anyone suggest how to throw exception to follow RI?
>
>
>
>
>
> On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> >
> > It's not clear why it should be non-bug diff?
> >
> > Shouldn't it be fixed to follow RI?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > Would any commiter like to confirm and close this "non-bug differences
> > from
> > > RI" jira? Thanks!
> > >
> > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > >
> > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > Date: Sep 13, 2006 11:02 AM
> > > > Subject: [jira] Commented: (HARMONY-1158)
> > [classlib][luni]Compatibility:
> > > > java.net.URL new URL("ss", null, -3, null) throws
> > MalformedURLException
> > > > while RI throws NPE
> > > > To: harmony-commits@incubator.apache.org
> > > >
> > > >    [
> > > >
> >
> http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > ]
> > > >
> > > > Andrew Zhang commented on HARMONY-1158:
> > > > ---------------------------------------
> > > >
> > > > Ilya, I agree with you. Spec has explicitly pointed out "No
> validation
> > of
> > > > the inputs is performed by this constructor."
> > > >
> > > > The tests show that the exception thrown sequence is uncertain and
> > > > implemention-dependent.
> > > >
> > > > If no application and test cases are broken by currenty Harmony
> code,
> > I
> > > > suggest not fix the problem.
> > > >
> > > > Best regards,
> > > > Andrew
> > > >
> > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null,
> -3,
> > > > null) throws MalformedURLException while RI throws NPE
> > > > >
> > > >
> >
> --------------------------------------------------------------------------------------------------------------------------
> > > > >
> > > > >                 Key: HARMONY-1158
> > > > >                 URL:
> > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > >             Project: Harmony
> > > > >          Issue Type: Bug
> > > > >          Components: Non-bug differences from RI
> > > > >            Reporter: Ilya Okomin
> > > > >
> > > > > Compatibility. Different order of exceptions.
> > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > > constructor if host ==null while Harmony at first checks port and
> > throws
> > > > MalformedURLException.
> > > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > > =============test.java=============
> > > > > import java.net.*;
> > > > > public class test  {
> > > > >     public static void main (String[] args) {
> > > > >        try {
> > > > >             new URL("ss", "0", -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >        try {
> > > > >             new URL("ss", null, -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >     }
> > > > > }
> > > > > =======================================
> > > > > Output on RI:
> > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > >         at java.net.URL.<init>(URL.java:373)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:7)
> > > > > java.lang.NullPointerException
> > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > >         at java.net.URL.<init>(URL.java:380)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:13)
> > > > > Output on Harmony:
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > > >         at test.main(test.java:7)
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > >
> > > > --
> > > > This message is automatically generated by JIRA.
> > > > -
> > > > If you think it was sent incorrectly contact one of the
> > administrators:
> > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > -
> > > > For more information on JIRA, see:
> > http://www.atlassian.com/software/jira
>
>

-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Ilya Okomin <il...@gmail.com>.
On 9/15/06, Andrew Zhang <zh...@gmail.com> wrote:

> On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> >
> > Ok, the second reason is convincing
>
>
> I also gave up to follow RI because of it! If anyone could fix this bug
> elegantly or not too ugly, I have no objection. :-) Otherwise, I  don't
> think following RI makes sense.  Thanks!


+1


> >Thanks,
> >Mikhail
>
> 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > There are two reasons:
> >
> > 1. Spec has explicitly pointed out "No validation of the inputs is
> performed
> > by this constructor."
> >
> > 2. The exception thrown sequence is really hard to follow, as described
> by
> > Ilya, see examples below:
> >
> > 1. new URL("ss", "0", -3, null);
> > java.net.MalformedURLException: Invalid port number :-3
> >
> > 2. new URL("ss", null, -3, null);
> > java.lang.NullPointerException
> >
> > 3. new URL("ss", "0", -3, "file");
> > java.net.MalformedURLException: Invalid port number :-3
> >
> > 4. new URL("ss", null, -3, "file");
> > java.net.MalformedURLException: unknown protocol: ss
> >
> > 5. new URL("ss", "0", -1, null);
> > java.lang.NullPointerException
> >
> > Yes, we should follow RI for exception thrown sequence if possible. But
> for
> > thise case, would anyone suggest how to throw exception to follow RI?
> >
> >
> >
> >
> >
> > On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> > >
> > > It's not clear why it should be non-bug diff?
> > >
> > > Shouldn't it be fixed to follow RI?
> > >
> > > Thanks,
> > > Mikhail
> > >
> > > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > > Would any commiter like to confirm and close this "non-bug
> differences
> > > from
> > > > RI" jira? Thanks!
> > > >
> > > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > > >
> > > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > > Date: Sep 13, 2006 11:02 AM
> > > > > Subject: [jira] Commented: (HARMONY-1158)
> > > [classlib][luni]Compatibility:
> > > > > java.net.URL new URL("ss", null, -3, null) throws
> > > MalformedURLException
> > > > > while RI throws NPE
> > > > > To: harmony-commits@incubator.apache.org
> > > > >
> > > > >    [
> > > > >
> > >
>
> http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > > ]
> > > > >
> > > > > Andrew Zhang commented on HARMONY-1158:
> > > > > ---------------------------------------
> > > > >
> > > > > Ilya, I agree with you. Spec has explicitly pointed out "No
> validation
> > > of
> > > > > the inputs is performed by this constructor."
> > > > >
> > > > > The tests show that the exception thrown sequence is uncertain and
> > > > > implemention-dependent.
> > > > >
> > > > > If no application and test cases are broken by currenty Harmony
> code,
> > > I
> > > > > suggest not fix the problem.
> > > > >
> > > > > Best regards,
> > > > > Andrew
> > > > >
> > > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null,
> -3,
> > > > > null) throws MalformedURLException while RI throws NPE
> > > > > >
> > > > >
> > >
>
> --------------------------------------------------------------------------------------------------------------------------
> > > > > >
> > > > > >                 Key: HARMONY-1158
> > > > > >                 URL:
> > > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > > >             Project: Harmony
> > > > > >          Issue Type: Bug
> > > > > >          Components: Non-bug differences from RI
> > > > > >            Reporter: Ilya Okomin
> > > > > >
> > > > > > Compatibility. Different order of exceptions.
> > > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > > > constructor if host ==null while Harmony at first checks port and
> > > throws
> > > > > MalformedURLException.
> > > > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > > > =============test.java=============
> > > > > > import java.net.*;
> > > > > > public class test  {
> > > > > >     public static void main (String[] args) {
> > > > > >        try {
> > > > > >             new URL("ss", "0", -3, null);
> > > > > >        } catch (Exception e) {
> > > > > >            e.printStackTrace();
> > > > > >        }
> > > > > >        try {
> > > > > >             new URL("ss", null, -3, null);
> > > > > >        } catch (Exception e) {
> > > > > >            e.printStackTrace();
> > > > > >        }
> > > > > >     }
> > > > > > }
> > > > > > =======================================
> > > > > > Output on RI:
> > > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > > >         at java.net.URL.<init>(URL.java:373)
> > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > >         at test.main(test.java:7)
> > > > > > java.lang.NullPointerException
> > > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > > >         at java.net.URL.<init>(URL.java:380)
> > > > > >         at java.net.URL.<init>(URL.java:283)
> > > > > >         at test.main(test.java:13)
> > > > > > Output on Harmony:
> > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > > >         at test.main(test.java:7)
> > > > > > java.net.MalformedURLException: Port out of range: -3
> > > > > >         at java.net.URL.<init>(URL.java:393)
> > > > > >         at java.net.URL.<init>(URL.java:367)
> > > > >
> > > > > --
> > > > > This message is automatically generated by JIRA.
> > > > > -
> > > > > If you think it was sent incorrectly contact one of the
> > > administrators:
> > > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > > -
> > > > > For more information on JIRA, see:
> > > http://www.atlassian.com/software/jira
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Andrew Zhang
> > > > > China Software Development Lab, IBM
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > 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
>
>
>
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>


-- 
--
Ilya Okomin
Intel Middleware Products Division

Re: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Andrew Zhang <zh...@gmail.com>.
On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
>
> Ok, the second reason is convincing


I also gave up to follow RI because of it! If anyone could fix this bug
elegantly or not too ugly, I have no objection. :-) Otherwise, I  don't
think following RI makes sense.  Thanks!

>Thanks,
>Mikhail

2006/9/14, Andrew Zhang <zh...@gmail.com>:
> There are two reasons:
>
> 1. Spec has explicitly pointed out "No validation of the inputs is
performed
> by this constructor."
>
> 2. The exception thrown sequence is really hard to follow, as described by
> Ilya, see examples below:
>
> 1. new URL("ss", "0", -3, null);
> java.net.MalformedURLException: Invalid port number :-3
>
> 2. new URL("ss", null, -3, null);
> java.lang.NullPointerException
>
> 3. new URL("ss", "0", -3, "file");
> java.net.MalformedURLException: Invalid port number :-3
>
> 4. new URL("ss", null, -3, "file");
> java.net.MalformedURLException: unknown protocol: ss
>
> 5. new URL("ss", "0", -1, null);
> java.lang.NullPointerException
>
> Yes, we should follow RI for exception thrown sequence if possible. But
for
> thise case, would anyone suggest how to throw exception to follow RI?
>
>
>
>
>
> On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> >
> > It's not clear why it should be non-bug diff?
> >
> > Shouldn't it be fixed to follow RI?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > Would any commiter like to confirm and close this "non-bug differences
> > from
> > > RI" jira? Thanks!
> > >
> > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > >
> > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > Date: Sep 13, 2006 11:02 AM
> > > > Subject: [jira] Commented: (HARMONY-1158)
> > [classlib][luni]Compatibility:
> > > > java.net.URL new URL("ss", null, -3, null) throws
> > MalformedURLException
> > > > while RI throws NPE
> > > > To: harmony-commits@incubator.apache.org
> > > >
> > > >    [
> > > >
> >
http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > ]
> > > >
> > > > Andrew Zhang commented on HARMONY-1158:
> > > > ---------------------------------------
> > > >
> > > > Ilya, I agree with you. Spec has explicitly pointed out "No
validation
> > of
> > > > the inputs is performed by this constructor."
> > > >
> > > > The tests show that the exception thrown sequence is uncertain and
> > > > implemention-dependent.
> > > >
> > > > If no application and test cases are broken by currenty Harmony
code,
> > I
> > > > suggest not fix the problem.
> > > >
> > > > Best regards,
> > > > Andrew
> > > >
> > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null,
-3,
> > > > null) throws MalformedURLException while RI throws NPE
> > > > >
> > > >
> >
--------------------------------------------------------------------------------------------------------------------------
> > > > >
> > > > >                 Key: HARMONY-1158
> > > > >                 URL:
> > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > >             Project: Harmony
> > > > >          Issue Type: Bug
> > > > >          Components: Non-bug differences from RI
> > > > >            Reporter: Ilya Okomin
> > > > >
> > > > > Compatibility. Different order of exceptions.
> > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > > constructor if host ==null while Harmony at first checks port and
> > throws
> > > > MalformedURLException.
> > > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > > =============test.java=============
> > > > > import java.net.*;
> > > > > public class test  {
> > > > >     public static void main (String[] args) {
> > > > >        try {
> > > > >             new URL("ss", "0", -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >        try {
> > > > >             new URL("ss", null, -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >     }
> > > > > }
> > > > > =======================================
> > > > > Output on RI:
> > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > >         at java.net.URL.<init>(URL.java:373)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:7)
> > > > > java.lang.NullPointerException
> > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > >         at java.net.URL.<init>(URL.java:380)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:13)
> > > > > Output on Harmony:
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > > >         at test.main(test.java:7)
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > >
> > > > --
> > > > This message is automatically generated by JIRA.
> > > > -
> > > > If you think it was sent incorrectly contact one of the
> > administrators:
> > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > -
> > > > For more information on JIRA, see:
> > http://www.atlassian.com/software/jira
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Andrew Zhang
> > > > China Software Development Lab, IBM
> > > >
> > >
> > >
> > >
> > > --
> > > 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





-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Mikhail Loenko <ml...@gmail.com>.
Ok, the second reason is convincing

Thanks,
Mikhail

2006/9/14, Andrew Zhang <zh...@gmail.com>:
> There are two reasons:
>
> 1. Spec has explicitly pointed out "No validation of the inputs is performed
> by this constructor."
>
> 2. The exception thrown sequence is really hard to follow, as described by
> Ilya, see examples below:
>
> 1. new URL("ss", "0", -3, null);
> java.net.MalformedURLException: Invalid port number :-3
>
> 2. new URL("ss", null, -3, null);
> java.lang.NullPointerException
>
> 3. new URL("ss", "0", -3, "file");
> java.net.MalformedURLException: Invalid port number :-3
>
> 4. new URL("ss", null, -3, "file");
> java.net.MalformedURLException: unknown protocol: ss
>
> 5. new URL("ss", "0", -1, null);
> java.lang.NullPointerException
>
> Yes, we should follow RI for exception thrown sequence if possible. But for
> thise case, would anyone suggest how to throw exception to follow RI?
>
>
>
>
>
> On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
> >
> > It's not clear why it should be non-bug diff?
> >
> > Shouldn't it be fixed to follow RI?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > > Would any commiter like to confirm and close this "non-bug differences
> > from
> > > RI" jira? Thanks!
> > >
> > > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > > >
> > > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > > Date: Sep 13, 2006 11:02 AM
> > > > Subject: [jira] Commented: (HARMONY-1158)
> > [classlib][luni]Compatibility:
> > > > java.net.URL new URL("ss", null, -3, null) throws
> > MalformedURLException
> > > > while RI throws NPE
> > > > To: harmony-commits@incubator.apache.org
> > > >
> > > >    [
> > > >
> > http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> > ]
> > > >
> > > > Andrew Zhang commented on HARMONY-1158:
> > > > ---------------------------------------
> > > >
> > > > Ilya, I agree with you. Spec has explicitly pointed out "No validation
> > of
> > > > the inputs is performed by this constructor."
> > > >
> > > > The tests show that the exception thrown sequence is uncertain and
> > > > implemention-dependent.
> > > >
> > > > If no application and test cases are broken by currenty Harmony code,
> > I
> > > > suggest not fix the problem.
> > > >
> > > > Best regards,
> > > > Andrew
> > > >
> > > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3,
> > > > null) throws MalformedURLException while RI throws NPE
> > > > >
> > > >
> > --------------------------------------------------------------------------------------------------------------------------
> > > > >
> > > > >                 Key: HARMONY-1158
> > > > >                 URL:
> > http://issues.apache.org/jira/browse/HARMONY-1158
> > > > >             Project: Harmony
> > > > >          Issue Type: Bug
> > > > >          Components: Non-bug differences from RI
> > > > >            Reporter: Ilya Okomin
> > > > >
> > > > > Compatibility. Different order of exceptions.
> > > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > > constructor if host ==null while Harmony at first checks port and
> > throws
> > > > MalformedURLException.
> > > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > > =============test.java=============
> > > > > import java.net.*;
> > > > > public class test  {
> > > > >     public static void main (String[] args) {
> > > > >        try {
> > > > >             new URL("ss", "0", -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >        try {
> > > > >             new URL("ss", null, -3, null);
> > > > >        } catch (Exception e) {
> > > > >            e.printStackTrace();
> > > > >        }
> > > > >     }
> > > > > }
> > > > > =======================================
> > > > > Output on RI:
> > > > > java.net.MalformedURLException : Invalid port number :-3
> > > > >         at java.net.URL.<init>(URL.java:373)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:7)
> > > > > java.lang.NullPointerException
> > > > >         at java.net.Parts.<init>(URL.java:1259)
> > > > >         at java.net.URL.<init>(URL.java:380)
> > > > >         at java.net.URL.<init>(URL.java:283)
> > > > >         at test.main(test.java:13)
> > > > > Output on Harmony:
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > > >         at test.main(test.java:7)
> > > > > java.net.MalformedURLException: Port out of range: -3
> > > > >         at java.net.URL.<init>(URL.java:393)
> > > > >         at java.net.URL.<init>(URL.java:367)
> > > >
> > > > --
> > > > This message is automatically generated by JIRA.
> > > > -
> > > > If you think it was sent incorrectly contact one of the
> > administrators:
> > > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > > -
> > > > For more information on JIRA, see:
> > http://www.atlassian.com/software/jira
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Andrew Zhang
> > > > China Software Development Lab, IBM
> > > >
> > >
> > >
> > >
> > > --
> > > 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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Andrew Zhang <zh...@gmail.com>.
There are two reasons:

1. Spec has explicitly pointed out "No validation of the inputs is performed
by this constructor."

2. The exception thrown sequence is really hard to follow, as described by
Ilya, see examples below:

1. new URL("ss", "0", -3, null);
java.net.MalformedURLException: Invalid port number :-3

2. new URL("ss", null, -3, null);
java.lang.NullPointerException

3. new URL("ss", "0", -3, "file");
java.net.MalformedURLException: Invalid port number :-3

4. new URL("ss", null, -3, "file");
java.net.MalformedURLException: unknown protocol: ss

5. new URL("ss", "0", -1, null);
java.lang.NullPointerException

Yes, we should follow RI for exception thrown sequence if possible. But for
thise case, would anyone suggest how to throw exception to follow RI?





On 9/14/06, Mikhail Loenko <ml...@gmail.com> wrote:
>
> It's not clear why it should be non-bug diff?
>
> Shouldn't it be fixed to follow RI?
>
> Thanks,
> Mikhail
>
> 2006/9/14, Andrew Zhang <zh...@gmail.com>:
> > Would any commiter like to confirm and close this "non-bug differences
> from
> > RI" jira? Thanks!
> >
> > On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> > >
> > > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > > Date: Sep 13, 2006 11:02 AM
> > > Subject: [jira] Commented: (HARMONY-1158)
> [classlib][luni]Compatibility:
> > > java.net.URL new URL("ss", null, -3, null) throws
> MalformedURLException
> > > while RI throws NPE
> > > To: harmony-commits@incubator.apache.org
> > >
> > >    [
> > >
> http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348
> ]
> > >
> > > Andrew Zhang commented on HARMONY-1158:
> > > ---------------------------------------
> > >
> > > Ilya, I agree with you. Spec has explicitly pointed out "No validation
> of
> > > the inputs is performed by this constructor."
> > >
> > > The tests show that the exception thrown sequence is uncertain and
> > > implemention-dependent.
> > >
> > > If no application and test cases are broken by currenty Harmony code,
> I
> > > suggest not fix the problem.
> > >
> > > Best regards,
> > > Andrew
> > >
> > > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3,
> > > null) throws MalformedURLException while RI throws NPE
> > > >
> > >
> --------------------------------------------------------------------------------------------------------------------------
> > > >
> > > >                 Key: HARMONY-1158
> > > >                 URL:
> http://issues.apache.org/jira/browse/HARMONY-1158
> > > >             Project: Harmony
> > > >          Issue Type: Bug
> > > >          Components: Non-bug differences from RI
> > > >            Reporter: Ilya Okomin
> > > >
> > > > Compatibility. Different order of exceptions.
> > > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > > constructor if host ==null while Harmony at first checks port and
> throws
> > > MalformedURLException.
> > > > If host != null both RI and Harmony throw MalformedURLException.
> > > > =============test.java=============
> > > > import java.net.*;
> > > > public class test  {
> > > >     public static void main (String[] args) {
> > > >        try {
> > > >             new URL("ss", "0", -3, null);
> > > >        } catch (Exception e) {
> > > >            e.printStackTrace();
> > > >        }
> > > >        try {
> > > >             new URL("ss", null, -3, null);
> > > >        } catch (Exception e) {
> > > >            e.printStackTrace();
> > > >        }
> > > >     }
> > > > }
> > > > =======================================
> > > > Output on RI:
> > > > java.net.MalformedURLException : Invalid port number :-3
> > > >         at java.net.URL.<init>(URL.java:373)
> > > >         at java.net.URL.<init>(URL.java:283)
> > > >         at test.main(test.java:7)
> > > > java.lang.NullPointerException
> > > >         at java.net.Parts.<init>(URL.java:1259)
> > > >         at java.net.URL.<init>(URL.java:380)
> > > >         at java.net.URL.<init>(URL.java:283)
> > > >         at test.main(test.java:13)
> > > > Output on Harmony:
> > > > java.net.MalformedURLException: Port out of range: -3
> > > >         at java.net.URL.<init>(URL.java:393)
> > > >         at java.net.URL.<init>(URL.java:367)
> > > >         at test.main(test.java:7)
> > > > java.net.MalformedURLException: Port out of range: -3
> > > >         at java.net.URL.<init>(URL.java:393)
> > > >         at java.net.URL.<init>(URL.java:367)
> > >
> > > --
> > > This message is automatically generated by JIRA.
> > > -
> > > If you think it was sent incorrectly contact one of the
> administrators:
> > > http://issues.apache.org/jira/secure/Administrators.jspa
> > > -
> > > For more information on JIRA, see:
> http://www.atlassian.com/software/jira
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Andrew Zhang
> > > China Software Development Lab, IBM
> > >
> >
> >
> >
> > --
> > 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: [classlib][luni] java.net.URL(String, String, int, String) constructor exception thrown sequence (was re: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3, null) throws MalformedURLException whil

Posted by Mikhail Loenko <ml...@gmail.com>.
It's not clear why it should be non-bug diff?

Shouldn't it be fixed to follow RI?

Thanks,
Mikhail

2006/9/14, Andrew Zhang <zh...@gmail.com>:
> Would any commiter like to confirm and close this "non-bug differences from
> RI" jira? Thanks!
>
> On 9/13/06, Andrew Zhang <zh...@gmail.com> wrote:
> >
> > From: Andrew Zhang (JIRA) <ji...@apache.org>
> > Date: Sep 13, 2006 11:02 AM
> > Subject: [jira] Commented: (HARMONY-1158) [classlib][luni]Compatibility:
> > java.net.URL new URL("ss", null, -3, null) throws MalformedURLException
> > while RI throws NPE
> > To: harmony-commits@incubator.apache.org
> >
> >    [
> > http://issues.apache.org/jira/browse/HARMONY-1158?page=comments#action_12434348]
> >
> > Andrew Zhang commented on HARMONY-1158:
> > ---------------------------------------
> >
> > Ilya, I agree with you. Spec has explicitly pointed out "No validation of
> > the inputs is performed by this constructor."
> >
> > The tests show that the exception thrown sequence is uncertain and
> > implemention-dependent.
> >
> > If no application and test cases are broken by currenty Harmony code, I
> > suggest not fix the problem.
> >
> > Best regards,
> > Andrew
> >
> > > [classlib][luni]Compatibility: java.net.URL new URL("ss", null, -3,
> > null) throws MalformedURLException while RI throws NPE
> > >
> > --------------------------------------------------------------------------------------------------------------------------
> > >
> > >                 Key: HARMONY-1158
> > >                 URL: http://issues.apache.org/jira/browse/HARMONY-1158
> > >             Project: Harmony
> > >          Issue Type: Bug
> > >          Components: Non-bug differences from RI
> > >            Reporter: Ilya Okomin
> > >
> > > Compatibility. Different order of exceptions.
> > > RI throws unspecified NPE in java.net.URL("ss", null, -3, null)
> > constructor if host ==null while Harmony at first checks port and throws
> > MalformedURLException.
> > > If host != null both RI and Harmony throw MalformedURLException.
> > > =============test.java=============
> > > import java.net.*;
> > > public class test  {
> > >     public static void main (String[] args) {
> > >        try {
> > >             new URL("ss", "0", -3, null);
> > >        } catch (Exception e) {
> > >            e.printStackTrace();
> > >        }
> > >        try {
> > >             new URL("ss", null, -3, null);
> > >        } catch (Exception e) {
> > >            e.printStackTrace();
> > >        }
> > >     }
> > > }
> > > =======================================
> > > Output on RI:
> > > java.net.MalformedURLException : Invalid port number :-3
> > >         at java.net.URL.<init>(URL.java:373)
> > >         at java.net.URL.<init>(URL.java:283)
> > >         at test.main(test.java:7)
> > > java.lang.NullPointerException
> > >         at java.net.Parts.<init>(URL.java:1259)
> > >         at java.net.URL.<init>(URL.java:380)
> > >         at java.net.URL.<init>(URL.java:283)
> > >         at test.main(test.java:13)
> > > Output on Harmony:
> > > java.net.MalformedURLException: Port out of range: -3
> > >         at java.net.URL.<init>(URL.java:393)
> > >         at java.net.URL.<init>(URL.java:367)
> > >         at test.main(test.java:7)
> > > java.net.MalformedURLException: Port out of range: -3
> > >         at java.net.URL.<init>(URL.java:393)
> > >         at java.net.URL.<init>(URL.java:367)
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > If you think it was sent incorrectly contact one of the administrators:
> > http://issues.apache.org/jira/secure/Administrators.jspa
> > -
> > For more information on JIRA, see: http://www.atlassian.com/software/jira
> >
> >
> >
> >
> >
> > --
> > Andrew Zhang
> > China Software Development Lab, IBM
> >
>
>
>
> --
> 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