You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Simon Kitching <sk...@apache.org> on 2005/07/18 04:48:31 UTC

Re: [lang] NotImplementedException getMessage() method has unexecutable code

On Sun, 2005-07-17 at 19:05 -0400, Steven Caswell wrote:
> In NotImplementedException, the getMessage() method has the following code:
> 
>     public String getMessage() {
>         if (super.getMessage() != null) {
>             return super.getMessage();
>         } else if (cause != null) {
>             return cause.toString();
>         } else {
>             return null;
>         }
>     }
> 
> Because of how the constructors are coded, unless I've missed
> something, super.getMessage() will always return a non-null value, so
> the else blocks will never execute. Did I read this correctly? Is
> there any reason to keep the additional else blocks? I'd like to
> remove them if there isn't.

I agree that super.getMessage() always returns non-null.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] NotImplementedException getMessage() method has unexecutable code

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Simon Kitching wrote:
>>Because of how the constructors are coded, unless I've missed
>>something, super.getMessage() will always return a non-null value, so
>>the else blocks will never execute. Did I read this correctly? Is
>>there any reason to keep the additional else blocks? I'd like to
>>remove them if there isn't.
> 
> 
> I agree that super.getMessage() always returns non-null.

This may vary by JDK version. I haven't checked, but isn't it better to 
code defensively here?

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org