[ 
https://issues.apache.org/jira/browse/OAK-2814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chetan Mehrotra updated OAK-2814:
---------------------------------
    Attachment: OAK-2814-v1.patch

[patch|^OAK-2814-v1.patch] for the same.

Earlier code in ObservationManager had a bug where the includePaths.remove 
triggers a ConcurrentModificationException as the iterator for that set is 
currently being used in outer loop
{code:linenumbers=true}
    private static void optimise(Set<String> includePaths, Set<String> 
excludedPaths) {
        Set<String> retain = newHashSet();
        for (String include : includePaths) {
            for (String exclude : excludedPaths) {
                if (exclude.equals(include) || isAncestor(exclude, include)) {
                    includePaths.remove(include);
                } else if (isAncestor(include, exclude)) {
                    retain.add(exclude);
                }
            }
        }
        excludedPaths.retainAll(retain);
    }
{code}

[~mduerig] Can you review the patch? Specially the contract examples mentioned 
in javadoc to ensure all aspects are covered

Also I was not able to create a scenario now for second clause in as now post 
your suggestion redundant includes would be removed anyway.
bq. if (exclude.equals(include) || isAncestor(exclude, include))

> Refactor the optimize logic regarding path include and exclude to avoid 
> duplication
> -----------------------------------------------------------------------------------
>
>                 Key: OAK-2814
>                 URL: https://issues.apache.org/jira/browse/OAK-2814
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Chetan Mehrotra
>            Assignee: Chetan Mehrotra
>            Priority: Minor
>              Labels: technical_debt
>             Fix For: 1.4
>
>         Attachments: OAK-2814-v1.patch
>
>
> {{ObservationManagerImpl}} has a optimize method which process the list of 
> includes and excludes and removes redundant clauses. That logic is now also 
> being used in index filtering (OAK-2599) and is getting duplicated.
> Going forward we need to refactor this logic so that both places can use it 
> without copying. Possibly making it part of PathUtils
> [~mduerig] Also suggested to further optimize
> bq. Also PathFilter#optimise could be further optimised by removing entries 
> that subsume each other (e.g. including /a/b, /a is the same as including 
> (/a. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to