[webbeans-dev] SimpleBean.create

Peter Royle howardmoon at screamingcoder.com
Sun Mar 29 15:03:04 EDT 2009


> 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 :).

> 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
> 





More information about the weld-dev mailing list