directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Ayyagari <kayyag...@apache.org>
Subject Re: DN, RDN and AVA imutability...
Date Mon, 27 Sep 2010 03:05:02 GMT
On Mon, Sep 27, 2010 at 3:30 AM, Emmanuel Lécharny <elecharny@apache.org> wrote:
>  On 9/26/10 11:30 PM, Stefan Seelmann wrote:
>>
>> 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()
>
> Fixed.
>>>
>>> RDN has many methods modifying it contents :
>>> clear(),
>>
>> This should be removed completele.
>
> Not necessarily. I will make it package protected, as it's used by the
> RdnParser. In other words,  the user won't be able to use it.
>>>
>>> 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.
>
> The addAttributeTypeAndValue should renamed to addAVA() IMO.
>>>
>>> DN has some too :
>>> DN( RDN )
>>> add( RDN )
>>> addAll( int posn, DN )
all these methods produce a new DN, so the original instance remains same
>>> addAllNormalized()
this is only used in the ServerContext.buildTarget() method, we can
remove it, but again
this produces a new DN
>>> getRdn()
>>> getRdn( int pos )
fixing RDN mutability issues will completely fix any issues with DN
mutability cause rest all modify
methods present in DN class will always return a new DN

>>> 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.
>
> Yes. I think that the normalize() methods are still there because we
> injected the schemaManager later in the design. We could get rid of it now,
> maybe.
I think not, calling normalize() won't change the structure of DN but
adds another presentation
to the user provided form which server understands, it is harmless to
have this in DN and also
helps us in normalizing an already created DN when schema manager is available
>>
>> 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.
>
> +1
>>
>> Alternatively, if the DN/RDN/AVA is already normalized, the
>> getNormalized() method can just return the actual object.
>
> yep.
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>

Kiran Ayyagari

Mime
View raw message