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 "Mauro Manfrin (JIRA)" <ji...@apache.org> on 2008/07/29 11:18:32 UTC

[jira] Reopened: (ECS-1) addElement(Element element) methods can fail

     [ https://issues.apache.org/jira/browse/ECS-1?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mauro Manfrin reopened ECS-1:
-----------------------------


Perfect, thank you...I really don't want to disturb you...
but some important adjustings are missing:
Here is the list:

org.apache.ecs.rtf.Alignment.java     fails because removeElementFromRegistry uses element hascode to remove an element. The patch is:

# This patch file was generated by NetBeans IDE
Index: Alignment.java
--- Alignment.java Base (BASE)
+++ Alignment.java Locally Modified (Based On LOCAL)
@@ -131,7 +131,7 @@
     */
     public Element removeElementFromRegistry(Element element)
     {
-        type.removeElementFromRegistry(Integer.toString(element.hashCode()));
+        type.removeElementFromRegistry(element);
         return(type);
     }



 
org.apache.ecs.StringElement.java    continues to fail beacuse still uses hashcodes!  The patch is:

# This patch file was generated by NetBeans IDE
Index: StringElement.java
--- StringElement.java Base (BASE)
+++ StringElement.java Locally Modified (Based On LOCAL)
@@ -105,7 +105,7 @@
      */
     public StringElement addElement(String element)
     {
-        addElement(Integer.toString(element.hashCode()),element);
+        addElementToRegistry(element);
         return(this);
     }
     



org.apache.ecs.html.Caption.java      continues to fail beacuse still uses hashcodes!  The patch is:

# This patch file was generated by NetBeans IDE
Index: Caption.java
--- Caption.java Base (BASE)
+++ Caption.java Locally Modified (Based On LOCAL)
@@ -77,7 +77,7 @@
     */
     public Caption addElement(String element)
     {
-        addElementToRegistry(Integer.toString(element.hashCode()),element);
\ No newline at end of file
+        addElementToRegistry(element);
\ No newline at end of file
         return(this);
     }



 
org.apache.ecs.html.Select.java      now uses a deprecated (and expensive) way of iterating on elements. The patch is:

# This patch file was generated by NetBeans IDE
Index: Select.java
--- Select.java Base (BASE)
+++ Select.java Locally Modified (Based On LOCAL)
@@ -177,10 +177,10 @@
 
     public Select selectOption(int option)
     {
-        Enumeration enum_ = keys();
+        Enumeration enum_ = elements();
         for(int x = 0; enum_.hasMoreElements(); x++)
         {
-            ConcreteElement element = (ConcreteElement)getElement((String)enum_.nextElement());
+            ConcreteElement element = (ConcreteElement)enum_.nextElement();
             if(x == option)
             {
                 ((Option)element).setSelected(true);


org.apache.ecs.xhtml.caption.java      continues to fail beacuse still uses hashcodes!  The patch is:

# This patch file was generated by NetBeans IDE
Index: caption.java
--- caption.java Base (BASE)
+++ caption.java Locally Modified (Based On LOCAL)
@@ -91,7 +91,7 @@
     */
     public caption addElement(String element)
     {
-        addElementToRegistry(Integer.toString(element.hashCode()),element);
+        addElementToRegistry(element);
         return(this);
     }
 


Thank you in advance. 
Mauro

> addElement(Element element) methods can fail
> --------------------------------------------
>
>                 Key: ECS-1
>                 URL: https://issues.apache.org/jira/browse/ECS-1
>             Project: ECS
>          Issue Type: Bug
>         Environment: in Ibm Virtual Machines, but probabily also in Sun Virtual Machines
>            Reporter: Mauro Manfrin
>            Assignee: Robert Burrell Donkin
>            Priority: Critical
>         Attachments: ecs-maintrunk-patches.zip, secondConcreteElement.zip
>
>
> 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.
> 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...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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