commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Commented: (CONFIGURATION-224) BaseConfiguration.getProperty() returns reference to intenal store collection object instead of a clone
Date Wed, 13 Sep 2006 20:18:23 GMT
Oliver Heger commented on CONFIGURATION-224:

I am still reluctant to add this copy operation to getProperty(). The getter methods that
deal with collections like getList() and getStringArray() will perform another copy because
they need to do interpolation. (So if somebody holds a collection or array returned by these
methods, there won't be a problem.)

Maybe the documentation of getProperty() should be changed to state that this method (depending
on a specific implementation) may return an object that is under the control of the configuration
instance and should not be manipulated or considered constant over time.

This won't help you with your current problem. But can't you do the copy yourself for collection
objects? I guess you will have a special treatment for collections anyway to compare the single
elements, haven't you?

> BaseConfiguration.getProperty() returns reference to intenal store collection object
instead of a clone
> -------------------------------------------------------------------------------------------------------
>                 Key: CONFIGURATION-224
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Bug
>         Environment: 1.3RC2
>            Reporter: Gabriele Garuglieri
>            Priority: Minor
>         Attachments: list.patch
> When the property object is a List or an Array, BaseConfiguration.getProperty() returns
a reference to the object contained in the store.
> This means that changing that object, changes the content of the properties store without
an explicit setProperty() or addProperty(). 
> Also any change to the object in the store will change the object that the code has reference
to, but the user is not aware that the property has changed unless he has added a ConfigurationListener.
> Attached a patch to make the object returned by BaseConfiguration.getProperty() a clone
of store content, to avoid side effects when changing Collection properties.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message