You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Michal (Jira)" <ji...@apache.org> on 2020/07/15 09:28:00 UTC

[jira] [Created] (JCRVLT-454) FilterSet equals method does not include ImportMode

Michal created JCRVLT-454:
-----------------------------

             Summary: FilterSet equals method does not include ImportMode
                 Key: JCRVLT-454
                 URL: https://issues.apache.org/jira/browse/JCRVLT-454
             Project: Jackrabbit FileVault
          Issue Type: Bug
          Components: vlt
    Affects Versions: 3.4.4
            Reporter: Michal


In the current implementation two filters definitions are equal:
<filter root="/etc/map" mode="replace" />
<filter root="/etc/map" mode="update" />
Only entries and root are used to calculate hashcode and equals comparisons:

[https://github.com/apache/jackrabbit-filevault/blob/0a4e5b89d67be926029c388bdb81e84d4b341222/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java#L284]

The solution could be:
{code:java}
public boolean equals(Object o) {
      if (this == o) return true;
      if (!(o instanceof FilterSet)) return false;
      FilterSet filterSet = (FilterSet) o;
      // importMode is @NotNull, can we depend on it? 
      if (!importMode.equals(filterSet.importMode)) return false; 
      if (entries != null ? !entries.equals(filterSet.entries) : filterSet.entries != null) return false;
      return root.equals(filterSet.root);
} {code}
{code:java}
public int hashCode() {
      int result = root.hashCode();
      // importMode is @NotNull, can we depend on it? 
      result = 31 * importMode.hashCode();
      result = 31 * result + (entries != null ? entries.hashCode() : 0);
      return result;
} {code}
 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)