ECS Deep Bug

"Mauro Manfrin" <[email protected]> Tue, 27 May 2008 15:06:33 +0200
Newsgroups gmane.comp.jakarta.ecs.devel
Message-ID <[email protected]>
Hello,

I'm contacting you to notify a Deep Bug I found on ECS project.

First of all, I want to tell you that my company and I, use ECS1.4.1 and 
then 1.4.2 as a kernel library for HTML page construction.
We use Ecs as a sort of base toolkit for our framework that's the base for 
our CRM solutions.
Nowaday, I think that more than 10000 telephone operators use our ecs based 
solution, 8 hours a day, in contact center applications. That's a real test 
environment.

Well. In the last installation, we used ecs on an AIX RISC JDK 1.5 platform 
and we found a strange bug.
I think that that bug affects all releases of ECS, because of a base mistake 
in ConcreteElement.java class.

Let's go to the real problem:
The class ConcreteElement exposes a method
addElement(Element element)
that calls
addElementToRegistry(Integer.toString(element.hashCode()),element);
so it gives a key valued element.hashCode() to that element.
That's the point: element.hashCode() can't be a unique key because sometimes 
we can have two elements with the same hasocode.
We experienced it only on IBM JDK, but the sun documentation (javadoc) 
states:

"It is not required that if two objects are unequal according to the 
equals(java.lang.Object) method, then calling the hashCode method on each of 
the two objects must produce distinct integer results. However, the 
programmer should be aware that producing distinct integer results for 
unequal objects may improve the performance of hashtables."

So sometimes, two different objects can have the same hashCode!
So, sometimes two calls to addElement(element) can result in only the second 
object stored in the ConcreteElement.
So sometimes, on out instalaltion some table rows misses, or some row cells 
misses or...

I think that's happening when IBM garbage collector compacts the heap, so 
that a new object can get same address (i.e. hashcode) of an old shifted 
object.

I've done some fixes to resolve.
I've done a version of ConcreteElement that sotores object in the Map only 
if you give explicitly a key-name, otherwise it stores only in the Vector. 
That seems to work good, with a good retro-compatibility.

I know that ECS is not in a work-inprogress state, but why don't give to the 
posterity a bugless software?


I rely on a feedback.
Thank you, Mauro