directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: DN, RDN and AVA imutability...
Date Sun, 26 Sep 2010 21:30:07 GMT
Hi Emmanuel,

On Sun, Sep 26, 2010 at 8:07 PM, Emmanuel Lecharny <elecharny@gmail.com> wrote:
>  Hi guys,
>
> while investigating the NPE Stefan pointed out today, I found that the DN,
> RDN and AVA are not completely immutable.
>
> AVA has two methods that can modify it :
> getNormValue(),
> getUpValue()
>
> RDN has many methods modifying it contents :
> clear(),

This should be removed completele.

> getAtav(),
> getAttributeTypeAndValue( String type ),
> getNormValue(),
> getUpValue(),
> getValue( String type ),
> iterator(),
> normalize( ... ) (all the methods),
> readExternal( ObjectInput in )

There are also two addAttributeTypeAndValue() and a setUpName() method.

>
> DN has some too :
> DN( RDN )
> add( RDN )
> addAll( int posn, DN )
> addAllNormalized()
> getRdn()
> getRdn( int pos )
> normalize(...)

Isn't that a paradox? The DN/RDN/AVA should be immutable. but we need
to modify them later in order to normalize them. IMO the only solution
is to have a constructor (or factory method) with a SchemaManager or
OID-Map parameter that normalizes the DN at construction time. The
normalize() methods should then be renamed to "getNormalized()", and
they don't modify the actual object, but create a new object by
calling the constructor (or factory method) with the schema manager.
Alternatively, if the DN/RDN/AVA is already normalized, the
getNormalized() method can just return the actual object.

> We have to fix those guys...

Thanks,
Stefan

Mime
View raw message