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

Sean Busbey edited comment on HBASE-20594 at 5/24/18 7:34 PM:
--------------------------------------------------------------

{code}
  // Need to check by element because array equality doesn't work
  private <T> void assertSetsEqual(Set<T> s1, Set<T> s2) {
    assertEquals(s1.size(), s2.size());
    for (T t : s1) {
      assertThat(s2, CoreMatchers.hasItem(t));
    }
  }
{code}

This is just the contract for {{Set.equals}}. It looks like Guava's 
{{ImmutableSet}} doesn't honor the contract, which is why we end up doing this 
here instead of just {{assertEquals(Set, Set)}}. If we switch to 
{{Collections.unmodifiableSet}} then we can also nix this bit and remove the 
hamcrest dependency.


was (Author: busbey):
{quote}
  // Need to check by element because array equality doesn't work
  private <T> void assertSetsEqual(Set<T> s1, Set<T> s2) {
    assertEquals(s1.size(), s2.size());
    for (T t : s1) {
      assertThat(s2, CoreMatchers.hasItem(t));
    }
  }
{quote}

This is just the contract for {{Set.equals}}. It looks like Guava's 
{{ImmutableSet}} doesn't honor the contract, which is why we end up doing this 
here instead of just {{assertEquals(Set, Set)}}. If we switch to 
{{Collections.unmodifiableSet}} then we can also nix this bit and remove the 
hamcrest dependency.

> provide utility to compare old and new descriptors
> --------------------------------------------------
>
>                 Key: HBASE-20594
>                 URL: https://issues.apache.org/jira/browse/HBASE-20594
>             Project: HBase
>          Issue Type: Improvement
>            Reporter: Mike Drob
>            Assignee: Mike Drob
>            Priority: Major
>         Attachments: HBASE-20594.patch, HBASE-20594.v2.patch, 
> HBASE-20594.v3.patch, HBASE-20594.v4.patch, HBASE-20594.v5.patch, 
> HBASE-20594.v6.patch
>
>
> HBASE-20567 gives us hooks that give both the old and new descriptor in 
> pre/postModify* events, but comparing them is still cumbersome. We should 
> provide users some kind of utility for this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to