You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/12/02 15:40:15 UTC
DO NOT REPLY [Bug 37667] -
[configuration] BaseConfiguration.addProperty() and MapConfiguration.addProperty() do not behave the same
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37667>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=37667
------- Additional Comments From smarc@gmx.net 2005-12-02 15:40 -------
I created the same test as you (copy/paste) and the assertion failed: size()
returns 1. As I tried to explain it in the bug description, adding properties to
existing values simply overwrites the preceeding ones.
I had a look at the code: AbstractConfiguration defines addProperty() which
calls the abstract addPropertyDirect(), which in turn is implemented in
MapConfiguration as follows:
protected void addPropertyDirect(String key, Object obj)
{
map.put(key, obj);
}
As Map.put() overwrites any existing values, the contract of addProperty is not
respected.
I downloaded the binaries and sources from the apache website, current the
version is 1.1.
So as it is working for you, I decided to look at the SVN version. The code for
addPropertyDirect seems to be better up there:
protected void addPropertyDirect(String key, Object value)
{
Object previousValue = getProperty(key);
if (previousValue == null)
{
map.put(key, value);
}
else if (previousValue instanceof List)
{
// the value is added to the existing list
((List) previousValue).add(value);
}
else
{
// the previous value is replaced by a list containing the previous
value and the new value
List list = new ArrayList();
list.add(previousValue);
list.add(value);
map.put(key, list);
}
}
So I think the bug I'm describing has been fixed, but is not currently available
in the latest release... When is the next release planned for?
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org