You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2010/05/15 10:36:26 UTC

Re: svn commit: r944590 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/interceptor/ core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/changelog/ core/src/main/j...

On 5/15/10 10:06 AM, felixk@apache.org wrote:
> Author: felixk
> Date: Sat May 15 08:06:07 2010
> New Revision: 944590
>
> URL: http://svn.apache.org/viewvc?rev=944590&view=rev
> Log:
> > From PMD report "Avoid empty catch blocks"
>    

I would not add a @SuppressWarning for such a warning. It's not good to 
have an empty catch block, and we should at least add a comment (// 
expected) if it's really expected, or add some real log if not.

I don't think that an empty catch block is a good thing (except in tests)


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com



Re: svn commit: r944590 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/interceptor/ core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/changelog/ core/src/main/j...

Posted by Felix Knecht <fe...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> I would not add a @SuppressWarning for such a warning. It's not good to
> have an empty catch block, and we should at least add a comment (//
> expected) if it's really expected, or add some real log if not.
> 
> I don't think that an empty catch block is a good thing (except in tests)

IMO it's never good swallowing an exception without leaving a trace
(either propagate exception or log exception).
Apart from that we may run into another problem, when catching any
thrown exception using the general "catch (Exception e)":

"This method uses a try-catch block that catches Exception objects, but
Exception is not thrown within the try block, and RuntimeException is
not explicitly caught. It is a common bug pattern to say try { ... }
catch (Exception e) { something } as a shorthand for catching a number
of types of exception each of whose catch blocks is identical, but this
construct also accidentally catches RuntimeException as well, masking
potential bugs. "


So what shall we do - propagate or log?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvuYicACgkQ2lZVCB08qHFJigCfe4ha2ToHocVsUxpFjLWAf1tI
QWcAnjKZxsdqrtT8iMn7NKdtsYe3q7wO
=DmL1
-----END PGP SIGNATURE-----