You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2017/10/20 00:50:59 UTC

[GitHub] ctubbsii commented on a change in pull request #313: ACCUMULO-4726 Add Value.contentEquals(byte[]) method

ctubbsii commented on a change in pull request #313: ACCUMULO-4726 Add Value.contentEquals(byte[]) method
URL: https://github.com/apache/accumulo/pull/313#discussion_r145858191
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/data/Value.java
 ##########
 @@ -242,16 +242,16 @@ public int compareTo(final byte[] that) {
 
   @Override
   public boolean equals(Object right_obj) {
-    // compare with byte[] for backwards compatibility, but this is generally a pretty bad practice
-    if (right_obj instanceof byte[]) {
-      return compareTo((byte[]) right_obj) == 0;
 
 Review comment:
   I thought about that, but also thought that could easily break things in surprising ways. Also, the portion of the API contract for `equals` that I was trying to fix was specifically the "symmetry" portion. Throwing an exception here leaves that broken, undermining what I was trying to accomplish.
   
   Also, I think people typically expect the question of equivalence to have an actual answer. Even null parameters are expected to have an answer and not throw NPE.
   
   I also considered adding a log message, but... this object is a simple "value object" POJO, which probably shouldn't have a logger (logging for those kinds of objects should really occur by the caller where the object is used).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services