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

Surenkumar Nihalani commented on HADOOP-9154:
---------------------------------------------

No worries about the name.

Just realized,
{{
  @SuppressWarnings("rawtypes")
  @Override
  public boolean equals(Object obj) {
    if(obj == null){
      return false;
    }
    if (this == obj) {
      return true;
    }
    if (obj.getClass() == this.getClass()) {
      Map other = (Map) obj;
      if (size() != other.size()) {
        return false;
      }
      return entrySet().equals(other.entrySet());
    }
    return false;
  }
  }}

Shouldn't we be using instanceof instead of matching for classes? because 
incase some class extends MapWritable, we won't hit the branch because of exact 
match of the class check.
                
> SortedMapWritable#putAll() doesn't add key/value classes to the map
> -------------------------------------------------------------------
>
>                 Key: HADOOP-9154
>                 URL: https://issues.apache.org/jira/browse/HADOOP-9154
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: io
>    Affects Versions: 2.0.2-alpha
>            Reporter: Karthik Kambatla
>            Assignee: Karthik Kambatla
>         Attachments: HADOOP-9124.patch, hadoop-9154-draft.patch
>
>
> In the following code from {{SortedMapWritable}}, #putAll() doesn't add 
> key/value classes to the class-id maps.
> {code}
>   @Override
>   public Writable put(WritableComparable key, Writable value) {
>     addToMap(key.getClass());
>     addToMap(value.getClass());
>     return instance.put(key, value);
>   }
>   @Override
>   public void putAll(Map<? extends WritableComparable, ? extends Writable> t){
>     for (Map.Entry<? extends WritableComparable, ? extends Writable> e:
>       t.entrySet()) {
>       
>       instance.put(e.getKey(), e.getValue());
>     }
>   }
> {code}

--
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

Reply via email to