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

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

I suggest to fix it like this: [^OAK-8948.patch]. This means your application 
would still face an exception when it tries to register a listener, but it 
would be more descriptive what is wrong.

[~sirin], WDYT?

> 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: OAK-8948.patch, Screen Shot 2020-03-13 at 2.25.07 
> PM.png, 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