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

Marcel Reutegger commented on OAK-8948:
---------------------------------------

The method {{ObservationManagerImpl.addEventListener()}} already has a {{null}} 
check on the absPath:
{noformat}
        String absPath = filter.getAbsPath();
        if (absPath != null) {
            includePaths.add(namePathMapper.getOakPath(absPath));
        }
{noformat}
That means, {{filter.getAbsPath()}} must return some invalid path value. 
{{PathMapper.getOakPath(String)}} is indeed allowed to return a null value:
{noformat}
    /**
     * Returns the Oak path for the given JCR path, or {@code null} if no
     * such mapping exists because the given JCR path contains a name element
     * with an unknown namespace URI or prefix, or is otherwise invalid.
     *
     * @param jcrPath JCR path
     * @return Oak path, or {@code null}
     */
    @Nullable
    String getOakPath(String jcrPath);
{noformat}

[~sirin], do you know what absPath is provided in your application via the 
JackrabbitEventFilter?

I think the addEventListener() method should have a check and throw an 
exception when it detects an invalid absPath.

> PathUtils. unifyInExcludes throws NPE when 'exclude' is null
> ------------------------------------------------------------
>
>                 Key: OAK-8948
>                 URL: https://issues.apache.org/jira/browse/OAK-8948
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: jackrabbit-api
>    Affects Versions: 1.8.17, 1.8.20
>            Reporter: rafiya sirin
>            Assignee: Marcel Reutegger
>            Priority: Major
>              Labels: Observation
>             Fix For: 1.8.21
>
>         Attachments: stacktrace.txt
>
>
> While registering a resource change listener, we encountered the following 
> exception : 
>  
> {code:java}
> 05.03.2020 23:39:00.728 *ERROR* [FelixDispatchQueue] 
> org.apache.sling.resourceresolver FrameworkEvent ERROR 
> (java.lang.NullPointerException)
> java.lang.NullPointerException: null
> at 
> org.apache.jackrabbit.oak.commons.PathUtils.unifyInExcludes(PathUtils.java:501)
>  [org.apache.jackrabbit.oak-commons:1.8.17]
> at 
> org.apache.jackrabbit.oak.jcr.observation.ObservationManagerImpl.addEventListener(ObservationManagerImpl.java:240)
>  [org.apache.jackrabbit.oak-jcr:1.8.17]
> at 
> org.apache.sling.jcr.resource.internal.JcrListenerBaseConfig.register(JcrListenerBaseConfig.java:136)
>  [org.apache.sling.jcr.resource:3.0.16.1]
> {code}
>  
> On further debugging, we found that issues lies in this snippet : 
> {code:java}
> if (exclude.equals(include) || isAncestor(exclude, include)) {
>  includesRemoved.add(include);{code}
> 'exclude' can be null if the getOakPath() method returns a null. This NPE 
> causes listeners(ResourceChangeListener in our case) to fail at registration.



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

Reply via email to