6 Replies Latest reply on Apr 28, 2007 3:16 PM by sammy8306

    default equals() doesn't behave as expected for javaBean com

    matt.drees

      I'm not sure whether this is a bug or not, but it occupied a chunk of my time trying to debug this, and I thought others should be aware of it.

      The javassist proxy for javaBeans components interferes with the default equals() method. After some interceptions, something like instance_javassist.equals(instance) is called, which fails, because they're different instances.

      You can see this with something like this (which fails):

      public class PingTest extends SeamTest {
      
       @Test
       public void test() throws Exception {
       new FacesRequest() {
       @Override
       protected void invokeApplication() {
       //call action methods here
       Ping ping = (Ping) getValue("#{ping}");
       Collection<Ping> pingSet = new ArrayList<Ping>();
       pingSet.add(ping);
       assert ping.equals(ping);
       }
       }.run();
       }
      }
      


      @Name("ping")
      public class Ping {
      
       @Logger private Log log;
      
       @In FacesMessages facesMessages;
      
       public void ping()
       {
       log.info("ping.ping() action called");
       facesMessages.add("ping");
       }
      
      
      }
      


      If it's a bug, I'll file it in jira.