You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ecs-dev@jakarta.apache.org by he...@eon-hanse.com on 2003/12/19 15:50:24 UTC
Bug in ConcreteElement
Hi ECS-developers.
I found a bug in ConcreteElement.
I did't find a possibility to send zhis bug to the Apache Bug Database
because there
isn't a project ECS, so I send this bug-description to this mailing-list.
Bug description:
If you add two different elements with the same hasCode to a
ConcreteElement, the first element
will be removed and the second element will replace the first element so
its in the wrong order.
Example:
org.apache.ecs.html.Select select = new org.apache.ecs.html.Select();
select.addElement(new org.apache.ecs.html.Option("1"));
select.addElement(new org.apache.ecs.html.Option("2"));
select.addElement(new org.apache.ecs.html.Option("3"));
If the first option and the third Option have the same hashCode you will
get this html:
<select>
<option value='3'></option>
<option value='2'></option>
</select>
Because hashcodes infrequent are the same of different objects (it depends
on the implementation
of Object.hashCode(); maybe different on different JVMs) the bug does not
often be there.
You only now:
a.equals(b) implies a.hashCode() == b.hashCode()
The implementation in ConcreteElement assumes that
a.hashCode() == b.hashCode() implies a.equals(b)
!!! But this is wrong !!!
See
org.apache.ecs.ConcreteElement.addElementToRegistry(Element)
Sincerely
Heiko Andresen
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org