0 Replies Latest reply on Dec 5, 2001 1:25 PM by AndrewGoedhart

    Remote.equals(null) should return false ??

    AndrewGoedhart Newbie

      Should a call to an EJB's remote interface of the form Remote.equals(null) return false or should it throw a null ppointer exception. Currently it is implemented on 2.4.3 and 3.0 alpha to throw a nullpointer exception.

      I think that it should just return false. This is also a problem because the 3.0 implmenetation of jetty perfroms the following test before inserting an item into the session.
      if( newValue != null && newValue.equals(oldValue))

      However oldvalue is null the very first time you set an item into the session and this means you can never add a remote EJB object because it always fails.

      Putting a guard condition into the BeanProxy class solves this problem though and I think it makes result returned by equals much more consistent.

      This change the new BeanProxy.isIdentical() method as follows

      protected Boolean isIdentical(Object a, Object b)
      throws RemoteException {
      if( a == null) return false;
      EJBObject ejb = (EJBObject) a;
      Object pk = ejb.getPrimaryKey();
      return new Boolean(pk.equals(b));
      }

      What is the general opinion of changing the way the equals() function works ? Is this more consistent??