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...@apache.org> on 2010/05/17 21:49:55 UTC

Danger of NPE

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

Following methods may throw an unexpected NPE, but I don't know what to
return as 'default' when testing for NPE.
is done.

Can please somebody with deeper knowledge fix this?

Methods are:

entry.someMethod is called before(!) the first test about entry==null!
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.html#277
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.html#360
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/codec/search/SearchResultEntryCodec.html#255

This if will NEVER be true because of line 1468!
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/entry/DefaultEntryAttribute.html#1474

This piece of code will never be reached because if line 54 - iterators
can't be null at this point!
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/util/JoinIterator.html#64

Thanks
Felix

PS:
I find it the easiest way to point to using links. If it's not ok please
insist.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvxneIACgkQ2lZVCB08qHEdpwCgw5T8qyv7dKNipam7C+RSrfKT
QBcAn08WXxJtx8mlwo4EtVki/mQklKpI
=2TWp
-----END PGP SIGNATURE-----

Re: Danger of NPE

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

On 05/17/10 22:05, Stefan Seelmann wrote:
> Felix Knecht schrieb:
>> This piece of code will never be reached because if line 54 - iterators
>> can't be null at this point!
>> http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/util/JoinIterator.html#64
> 
> JoinIterator seems never be used, except in JoinIteratorTest. I'd
> suggest to delete both classes.
> 
> Can findbugs or other static analysis tools be used to find unused code?

PMD [1] report can find some of them:

Here are quite up to date PMD reports of shared and apacheds. If you
want me to update them please ping me.

http://people.apache.org/~felixk/shared-docs/pmd.html
http://people.apache.org/~felixk/apacheds-docs/pmd.html

HTH
Felix

[1] http://pmd.sourceforge.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvxpjMACgkQ2lZVCB08qHHNMQCgnrDGZk8falnSpBL2PyUTq4TY
blsAnibw5/NmTLgGEkWrFNT1YTPgl4Rd
=90MW
-----END PGP SIGNATURE-----

Re: Danger of NPE

Posted by Stefan Seelmann <se...@apache.org>.
Felix Knecht schrieb:
> This piece of code will never be reached because if line 54 - iterators
> can't be null at this point!
> http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/util/JoinIterator.html#64

JoinIterator seems never be used, except in JoinIteratorTest. I'd
suggest to delete both classes.

Can findbugs or other static analysis tools be used to find unused code?

Kind Regards,
Stefan