You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Felix Knecht <fe...@otego.com> on 2010/05/15 09:38:35 UTC

Is this Exception catch really wanted?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all

In LdapCoreSessionConnection.java we have multiple constructs like (see
below). The methods declares tho throw 2 Exceptions, but with this
construct they are never thrown. Is this on purpose?

public BindResponse bind() throws LdapException, IOException
{
    try
    {
        setSession( directoryService.getSession() );
    }
    catch( Exception e )
    {
    }
    return null;
}

More samples:
http://people.apache.org/~felixk/apacheds-docs/xref/org/apache/directory/server/core/LdapCoreSessionConnection.html#504
http://people.apache.org/~felixk/apacheds-docs/xref/org/apache/directory/server/core/LdapCoreSessionConnection.html#525
...

Felix

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvuT3sACgkQ2lZVCB08qHFGiACg3kq+vbD+p2zxSKRawI5seMHD
mqUAn1C7XfhZcAGi89r9NIiZElfJfJUs
=7pqw
-----END PGP SIGNATURE-----

Re: Is this Exception catch really wanted?

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

Hi Kiran

Thanks for quick reply. I'll annotate them as false positives in this case.

Felix

On 05/15/10 10:07, Kiran Ayyagari wrote:
> hi Felix,
> 
>> In LdapCoreSessionConnection.java we have multiple constructs like (see
>> below). The methods declares tho throw 2 Exceptions, but with this
>> construct they are never thrown. Is this on purpose?
> yeah, cause in this implementation of LdapConnection interface there
> is no network layer
> involved and the throws clause is just there to adhere to the
> interface signatures
> 
> can fill the catch block with a log statement if required to avoid
> false positives in the reports
> 
> Kiran Ayyagari
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvuWBUACgkQ2lZVCB08qHFkjgCgzOb9Aj4B4pDfkZtU9jgpE1O4
JxoAn1fP2WGoeFpJVdJFqIqpMG8F7eI5
=5u8c
-----END PGP SIGNATURE-----

Re: Is this Exception catch really wanted?

Posted by Kiran Ayyagari <ka...@apache.org>.
On Sat, May 15, 2010 at 11:34 AM, Emmanuel Lecharny <el...@gmail.com> wrote:
> I'm just wondering if the method signature is correct ? Why would we throw
> an exception in the setSession() method ? Either the session is null, and we
> should throw an IllegalArgumentException, or we should not throw anything.

all those method signatures are just defined following the
LdapConnection interface


Kiran Ayyagari

Re: Is this Exception catch really wanted?

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 5/15/10 10:15 AM, Stefan Seelmann wrote:
> Let's add a comment into each empty catch block to describe why the
> exception is catched and not handled so another developer can see the
> reason.
>    

I'm just wondering if the method signature is correct ? Why would we 
throw an exception in the setSession() method ? Either the session is 
null, and we should throw an IllegalArgumentException, or we should not 
throw anything.

IMHO, the setSession() should not throw anything. In all case, the 
concern Felix raised is interesting and should lead to some thoughts 
about the cause of the concern, instead of shutting it down by adding 
some log or some @suppressWarning, don't you think so ?

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



Re: Is this Exception catch really wanted?

Posted by Alex Karasulu <ak...@apache.org>.
On Sat, May 15, 2010 at 11:15 AM, Stefan Seelmann <se...@apache.org>wrote:

> Let's add a comment into each empty catch block to describe why the
> exception is catched and not handled so another developer can see the
> reason.
>
>
+1



> Kiran Ayyagari wrote:
> > hi Felix,
> >
> >> In LdapCoreSessionConnection.java we have multiple constructs like (see
> >> below). The methods declares tho throw 2 Exceptions, but with this
> >> construct they are never thrown. Is this on purpose?
> > yeah, cause in this implementation of LdapConnection interface there
> > is no network layer
> > involved and the throws clause is just there to adhere to the
> > interface signatures
> >
> > can fill the catch block with a log statement if required to avoid
> > false positives in the reports
> >
> > Kiran Ayyagari
>
>


-- 
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://directory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu

Re: Is this Exception catch really wanted?

Posted by Stefan Seelmann <se...@apache.org>.
Let's add a comment into each empty catch block to describe why the
exception is catched and not handled so another developer can see the
reason.

Kiran Ayyagari wrote:
> hi Felix,
> 
>> In LdapCoreSessionConnection.java we have multiple constructs like (see
>> below). The methods declares tho throw 2 Exceptions, but with this
>> construct they are never thrown. Is this on purpose?
> yeah, cause in this implementation of LdapConnection interface there
> is no network layer
> involved and the throws clause is just there to adhere to the
> interface signatures
> 
> can fill the catch block with a log statement if required to avoid
> false positives in the reports
> 
> Kiran Ayyagari


Re: Is this Exception catch really wanted?

Posted by Kiran Ayyagari <ka...@apache.org>.
hi Felix,

> In LdapCoreSessionConnection.java we have multiple constructs like (see
> below). The methods declares tho throw 2 Exceptions, but with this
> construct they are never thrown. Is this on purpose?
yeah, cause in this implementation of LdapConnection interface there
is no network layer
involved and the throws clause is just there to adhere to the
interface signatures

can fill the catch block with a log statement if required to avoid
false positives in the reports

Kiran Ayyagari