jakarta-ecs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From heiko.andre...@eon-hanse.com
Subject Bug in ConcreteElement
Date Fri, 19 Dec 2003 14:50:24 GMT

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.

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:
      <option value='3'></option>
      <option value='2'></option>

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 !!!


  Heiko Andresen

To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org

View raw message