[webbeans-dev] SimpleBean.create

Pete Muir pmuir at redhat.com
Sun Mar 29 19:33:28 EDT 2009


On 29 Mar 2009, at 20:41, Peter Royle wrote:

> Actually this is probably the safer way to do it:
> http://fisheye.jboss.com/changelog/Webbeans/?cs=2255.
>
> The previous commit changed the behaviour in a couple of subtle ways
> which is not a particularly good thing.

Explain - I can't see how this is currently safe given that you will  
get a CCE if I do

dependentStorageRequest.equals(new String());

Anyway, I made this use the standard equals idiom and the test suite  
appears unaffected...

>
>
> Pete.
>
>
> On Sun, 2009-03-29 at 19:03 +0000, Peter Royle wrote:
>>> A try-finally doesn't swallow exceptions,
>>
>> That's what I thought! But all bets are off when the finally block
>> throws an uncaught exception :).

Yes, so (as you say) we make it so we don't throw an exception there :-)

>>
>>
>>> and a catch-rethrow is not necessary unless you need to inspect  
>>> the exception somehow (e.g. to
>>> provide more context) and swallow-log is a horrible approach.
>>
>> Agreed :)
>>
>>> I suspect you have some other problem, probably inside the logic  
>>> which
>>> rethrows exceptions invoking constructors as CreationExceptions.
>>
>> The problem in this case is that an NPE is thrown in the finally  
>> block
>> because it relies on a variable which is initialiesd in the try block
>> which bailed out. This new NPE causes the original exception to be
>> buried.
>>
>> The fix is easy though - I've jsut made DependentStorageRequest  
>> capable
>> of comparing against null.
>> http://fisheye.jboss.com/changelog/Webbeans/?cs=2254
>>
>> Cheers,
>>
>> Pete.
>>
>>>
>>> On 24 Mar 2009, at 21:55, Peter Royle wrote:
>>>
>>>> Hi,
>>>>
>>>> I've noticed that if I do something stupid in one of my bean's
>>>> constructors (a NPE for example ;) the exception is being buried by
>>>> SimpleBean.create which has 'trys' and 'finallys' but no catch. I
>>>> assume
>>>> there's a good reason for not rethrowing the exception here (what  
>>>> is
>>>> it
>>>> by the way?), but could we maybe log it?
>>>>
>>>> Cheers,
>>>>
>>>> Pete.
>>>>
>>>>
>>>> _______________________________________________
>>>> webbeans-dev mailing list
>>>> webbeans-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/webbeans-dev
>>>
>>> --
>>> Pete Muir
>>> http://www.seamframework.org
>>> http://in.relation.to/Bloggers/Pete
>>>
>>
>>
>> _______________________________________________
>> webbeans-dev mailing list
>> webbeans-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/webbeans-dev
>
>
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/webbeans-dev

--
Pete Muir
http://www.seamframework.org
http://in.relation.to/Bloggers/Pete




More information about the weld-dev mailing list