camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcb55 <mcbenne...@dnb.com>
Subject Why do Camel core methods still throw Checked Exceptions (everyone agrees they're 'bad' now, right?)
Date Sun, 12 May 2013 11:17:54 GMT
I've been using Camel for a while (and it's great), but one issue bugs me -
many of the methods in the core Camel interfaces throw Checked Exceptions,
e.g. the fundamental 'void process(Exchange exchange) *throws Exception*;',
or CamelContext methods, like 'addRoutes()' or 'start()'.

Doesn't the Java world now pretty-much accept that Checked Exceptions are
generally bad, isn't this debate over
(http://jyops.blogspot.ie/2012/03/why-should-you-use-unchecked-exceptions.html)?!

Hibernate already made the decision to drop Checked Exceptions:
http://stackoverflow.com/questions/4609870/why-hibernate-changed-hibernateexception-to-runtimeexception-unchecked,
and isn't Camel in the same class of 'thing' as Hibernate - i.e. a very
widely used Java developer framework.

Does the Camel community still think they are 'good'? I don't! Maybe it's
just that a change would be backward-compatibility-breaking, and maybe it's
on the cards for Camel 3.0 - so I'm just asking (I couldn't find anything
searching this site).

So rather than expose these nasty Checked Exceptions to my code (because
they tend to ripple up, or I have stupid try{}/catch(Exception){}' blocks in
my code, I'm considering wrapping *all* the Camel calls (that my code uses)
in methods that just catch these 'Exceptions' and throw 'RuntimeExceptions'
instead.

PMD already has a warning about signatures using 'throws Exception':
SignatureDeclareThrowsException (so Camel falls down there already!), but
even my wrapper code will get caught out by the related PMD warning of
AvoidCatchingGenericException
(http://pmd.sourceforge.net/pmd-4.2.6/rules/strictexception.html).

Wouldn't all this nastiness go away if Camel went the Hibernate route (and
the wider industry route!?) and just dropped Checked Exceptions...? Is there
any general community advice for current Camel 2.x users (e.g. just wrap the
'offending' methods if you don't like them!)??

And I'm really just asking the question here - there's no need for a
Checked/Unchecked debate. If the Camel community (or just the committers)
consider the current situation appropriate then I'm perfectly fine with
that, and I'll just go with the wrapper methods for my systems.

Pat.




--
View this message in context: http://camel.465427.n5.nabble.com/Why-do-Camel-core-methods-still-throw-Checked-Exceptions-everyone-agrees-they-re-bad-now-right-tp5732364.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message