accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Havanki (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ACCUMULO-1627) Add hashcode() and equals() to ConditionalMutation
Date Fri, 27 Sep 2013 18:09:02 GMT

    [ https://issues.apache.org/jira/browse/ACCUMULO-1627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13780178#comment-13780178
] 

Bill Havanki commented on ACCUMULO-1627:
----------------------------------------

See [discussion on ACCUMULO-1734|https://issues.apache.org/jira/browse/ACCUMULO-1734?focusedCommentId=13780097&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13780097]
for background.

The method {{Mutation.equals(Mutation)}} is problematic for implementing {{equals()}} properly
in a subclass. In short, for some object {{o}} of a subclass type {{SubMutation}}, a call
to {{o.equals(m)}} where {{m}} is a {{Mutation}} will be bound to {{Mutation.equals(Mutation)}},
not {{SubMutation.equals(Object)}}. This is because the {{Mutation}} method has a more specific
argument type, so the compiler prefers it over the proper one in the subclass. This is a problem
for preserving symmetry for {{equals()}} as well as for checking additional fields in the
subclass.

{code:java}
Mutation m = /* some mutation */;
SubMutation sm = /* some other mutation */;
sm.equals(m); /* <- bound to Mutation.equals(Mutation) */
{code}

To remedy this I had thought to protect/rename {{Mutation.equals()}}, relegating it to a utility
comparison method which it appears to be. However, as Keith suspected, this would break ABI
compatibility. Code compiled against the old version would throw {{NoSuchMethodError}}.

Another option is to have each {{Mutation}} subclass also override {{equals(Mutation)}}. It's
messy but it should work.

So, what is the best path according to the development policies for Accumulo? "Fix" the API
at the expense of breaking the ABI, or introduce (modest) warts to work with what already
exists?

Thanks all.
                
> Add hashcode() and equals() to ConditionalMutation
> --------------------------------------------------
>
>                 Key: ACCUMULO-1627
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-1627
>             Project: Accumulo
>          Issue Type: Sub-task
>          Components: client, tserver
>            Reporter: Keith Turner
>            Assignee: Bill Havanki
>              Labels: newbie
>             Fix For: 1.6.0
>
>
> ConditionalMutation should define equals() and hashcode() methods that consider the conditions.
  Its parent class defines those methods, so it should.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message