harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <g...@pobox.com>
Subject Re: [general]what do you think about this kind of exception order?
Date Fri, 22 Dec 2006 18:09:46 GMT
I don't grok.  You are talking about test behavior?  or some API  
behavior?  I'm guessing the latter.

geir

On Dec 22, 2006, at 11:52 AM, Tony Wu wrote:

> There are two methods, which throw exceptions in different order.
>
> public test1(int a, int b){
>    if(a>b){
>        throw AException();
>    }
>    synchronized(obj){
>       if(blabla){
>           throw BException();
>       }
>   }
> }
>
> public test2(int a, int b){
>   synchronized(obj){
>       if(blabla){
>           throw BException();
>       }
>       if(a>b){
>           throw AException();
>       }
>   }
> }
>
>
> test1 checks the parameters before entering the synchronized block, It
> returns immediately instead of waiting for a lock in the condition
> which should throw AException. IMHO, test1 is more elegant. The
> problem is, if RI do something like the test2 where harmony using
> test1, should we follow RI here? What's your opinion?
>
> Thanks.
>
> -- 
> Tony Wu
> China Software Development Lab, IBM


Mime
View raw message