You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2018/01/31 15:14:00 UTC

[jira] [Comment Edited] (SLING-7456) FlushCache in SlingServletResolver can throw an NPE

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

Carsten Ziegeler edited comment on SLING-7456 at 1/31/18 3:13 PM:
------------------------------------------------------------------

[~karlpauls] The listener is only registered if cache is not null:

[https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java#L865]

The check for the jmx bean at [https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java#L879] should be changed

However in your stack trace, the listener is invoked. As that seems to be a scheduled thread, I assume the servlets resolver is already disposed (where cache has been set to null). So we should check for null in flush just to avoid this situation


was (Author: cziegeler):
[~karlpauls] The listener is only registered if cache is not null:

[https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java#L865]

The check for the jmx bean at [https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java#L879] should be changed

However in your stack trace, the listener is invoked, which according to the code can't happen

> FlushCache in SlingServletResolver can throw an NPE
> ---------------------------------------------------
>
>                 Key: SLING-7456
>                 URL: https://issues.apache.org/jira/browse/SLING-7456
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Resolver 2.4.22
>            Reporter: Karl Pauls
>            Priority: Minor
>             Fix For: Servlets Resolver 2.4.24
>
>
> Given that we check for the this.cache being null everytime we reference the cache we should probably do the same in flushCache. I can't reproduce it but the NPE looked like this:
> {noformat}
> java.lang.NullPointerException: null
> 	at org.apache.sling.servlets.resolver.internal.SlingServletResolver.flushCache(SlingServletResolver.java:1122) [org.apache.sling.servlets.resolver:2.4.22]
> 	at org.apache.sling.servlets.resolver.internal.SlingServletResolver.onChange(SlingServletResolver.java:1464) [org.apache.sling.servlets.resolver:2.4.22]
> 	at org.apache.sling.resourceresolver.impl.observation.BasicObservationReporter.reportChanges(BasicObservationReporter.java:211) [org.apache.sling.resourceresolver:1.5.34]
> 	at org.apache.sling.jcr.resource.internal.JcrResourceListener.onEvent(JcrResourceListener.java:155) [org.apache.sling.jcr.resource:3.0.8]
> 	at org.apache.jackrabbit.commons.observation.ListenerTracker$1.onEvent(ListenerTracker.java:190) [org.apache.jackrabbit.jackrabbit-jcr-commons:2.16.0]
> 	at org.apache.jackrabbit.oak.jcr.observation.ChangeProcessor.contentChanged(ChangeProcessor.java:508) [org.apache.jackrabbit.oak-jcr:1.8.1]
> 	at org.apache.jackrabbit.oak.plugins.observation.FilteringDispatcher.contentChanged(FilteringDispatcher.java:53) [org.apache.jackrabbit.oak-core:1.8.1]
> 	at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:128) [org.apache.jackrabbit.oak-store-spi:1.8.1]
> 	at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:122) [org.apache.jackrabbit.oak-store-spi:1.8.1]
> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
> 	at java.base/java.lang.Thread.run(Thread.java:844)
> {noformat}



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