hk2
  1. hk2
  2. HK2-96

ConfigBeanProxy equals always returns false

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.1.*
    • Fix Version/s: 2.4.0
    • Component/s: None
    • Labels:
      None

      Description

      The equals method between two ConfigBeanProxy objects (config beans) always returns false.
      If you have some config bean

      @Configured
      public interface MyBean implements ConfigBeanProxy

      { ... }

      and and instance of MyBean "a", then

      a.equals(a) is always false when you do this within a transaction, where a is actually a WriteableView. (I didn't check this for the non-transaction case.)

      The root cause is that the equals methods on the Proxy is sent to the InvocationHandler, in this case WriteableView. The invoke method has:

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

      if (method.getName().equals("hashCode"))
      return super.hashCode();

      if (method.getName().equals("equals"))
      return super.equals(args[0]);

      Here, "this" is a WriteableView, but "args[0]" is another proxy. It seems that this last line should be:

      return super.equals(Proxy.getInvocationHandler(args[0]));

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Mahesh Kannan
            Reporter:
            Tom Mueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: