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/19 07:06:07 UTC

Wrong interface or dead code

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

In following methods exists either dead code or the method parameter is
wrong defined (name is per definition always of instance X and never
something else). As I don't now if there are somewhere missing testcases
or not I'm not sure, which is the case and if the method footprint has
to be fixed or if the code can be eliminated.

http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/name/DN.html#964
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/schema/comparators/ComparableComparator.html#64
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.html#69
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/util/NamespaceTools.html#114

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

iEYEARECAAYFAkvzcb8ACgkQ2lZVCB08qHHVdwCgzLjkOQHkKPvRPhHLqYQukljH
SLkAnRQcXOx56YnMIAVMJupWA9D0KTRC
=bzM9
-----END PGP SIGNATURE-----

Re: Wrong interface or dead code

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

On 05/19/10 10:39, Emmanuel Lecharny wrote:
> On 5/19/10 7:06 AM, Felix Knecht wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> In following methods exists either dead code or the method parameter is
>> wrong defined (name is per definition always of instance X and never
>> something else). As I don't now if there are somewhere missing testcases
>> or not I'm not sure, which is the case and if the method footprint has
>> to be fixed or if the code can be eliminated.
>>    
> I'm not sure I understand the problem... Are those methods never used
> anywhere ?

If they are never used I don't now, but to show the problem:

- - The param 'name' is defined as 'DN' (in the methods parameters).
- - The "if (name instanceOf DN)" doesn't make sense, because it must be
instanceOf DN. Otherwise this method isn't called.

Conclusion:
- - Either we can drop the if and the content of the else
- -or the methods parameter is wrong and should be
public DN addAllNormalized( int posn, Object name )
and then the else may throw the LdapInvalidDnException


964     public DN addAllNormalized( int posn, DN name ) throws
LdapInvalidDnException
965     {
966         if ( name instanceof DN )
967         {
968             DN dn = (DN)name;
969
970             if ( ( dn == null ) || ( dn.size() == 0 ) )
971             {
972                 return this;
973             }
974
975             // Concatenate the rdns
976             rdns.addAll( size() - posn, dn.rdns );
977
978             if ( StringTools.isEmpty( normName ) )
979             {
980                 normName = dn.normName;
981                 bytes = dn.bytes;
982                 upName = dn.upName;
983             }
984             else
985             {
986                 normName = dn.normName + "," + normName;
987                 bytes = StringTools.getBytesUtf8( normName );
988                 upName = dn.upName + "," + upName;
989             }
990         }
991         else
992         {
993             if ( ( name == null ) || ( name.size() == 0 ) )
994             {
995                 return this;

> 
> 

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

iEYEARECAAYFAkvzp5YACgkQ2lZVCB08qHGfxgCffFok5BuFXEmJlQFnmUGYIaS9
W3gAnAjZ1Zd0KnEvWDFM1e11sPopw/4l
=vJ5j
-----END PGP SIGNATURE-----

Re: Wrong interface or dead code

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 5/19/10 7:06 AM, Felix Knecht wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> In following methods exists either dead code or the method parameter is
> wrong defined (name is per definition always of instance X and never
> something else). As I don't now if there are somewhere missing testcases
> or not I'm not sure, which is the case and if the method footprint has
> to be fixed or if the code can be eliminated.
>    
I'm not sure I understand the problem... Are those methods never used 
anywhere ?


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