admin@glassfish.java.net

Re: CODE REVIEW: FindBugs: admin/servermgmt/src/java/com/sun/enterprise/admin/servermgmt

From: Kedar Mhaswade <Kedar.Mhaswade_at_Sun.COM>
Date: Fri, 04 May 2007 01:12:16 -0700

>>
>> finally {
>> - if (bis != null)
>> + if (bis != null) {
>> try {
>> bis.close();
>> - } catch(Exception ee) {}
>> + } catch(Exception ee) {
>> + IGNORE_EXCEPTION(ee);
>> }
>> }
>> + }
>> + }
>> +
>> +
>> + private static void IGNORE_EXCEPTION(final Exception e ) {
>> + // ignore
>> + }
>> +
>> private boolean serviceNameExists(final String sn) {
>> boolean exists = false;
>> try {
>>
>
> Usually it's enough to do:
>
> try {
> ...
> } catch (Exception ex) {
> // ignore
> }
>
> Did that not work here?
>
I wonder why it won't work here.
Moreover, I still think that it is OK to leave it without even a
comment, because
this *particular* place is such a boiler-plate code. While doing any
reading/writing
of the streams you opened in a method, just make sure that you
"finally" make an attempt to close
them and if it fails -- tough luck.

It is fine to document the code by putting a comment like // ignore, but
in this
repetitive pattern, it's OK to just squelch it as well.