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

Dirk Rudolph reassigned SLING-11132:
------------------------------------

    Assignee: Dirk Rudolph

> Exception handling while clearing OSGiServiceReferences
> -------------------------------------------------------
>
>                 Key: SLING-11132
>                 URL: https://issues.apache.org/jira/browse/SLING-11132
>             Project: Sling
>          Issue Type: Improvement
>          Components: Sling Models
>    Affects Versions: Models Implementation 1.5.0
>            Reporter: Sagar Miglani
>            Assignee: Dirk Rudolph
>            Priority: Major
>          Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> *"Sling Models OSGi Service Disposal Job"* to clean the OSGi service 
> references does not do any error handling.
> If a ungetting of a reference [0] is failed due to some exception (like 
> java.lang.IllegalStateException: Invalid BundleContext) no more references 
> present in queue are cleaned up in same job trigger. The next reference in 
> queue will be tried after 30 seconds (default) in next job trigger. 
> Therefore, it may take an hour to clean up 120 references with an error.
> To reproduce this:
>  # Create a model consisting of OSGiService Injection
>  # Use this model in a page
>  # Open the created page and refresh it couple of time (10-15)
>  # Restart the bundle with model created in step 1
>  # One may see the following exceptions in the logs (after every ~30 seconds 
> to clear up the OSGi service references)
> {code:xml}
> 01.02.2021 14:31:03.639 *ERROR* [sling-default-1-Sling Models OSGi Service 
> Disposal Job] org.apache.sling.commons.scheduler.impl.QuartzScheduler 
> Exception during job execution of job 
> 'org.apache.sling.models.impl.ModelAdapterFactory@1b834b3c' with name 'Sling 
> Models OSGi Service Disposal Job' : Invalid BundleContext.
> java.lang.IllegalStateException: Invalid BundleContext.
>       at 
> org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:491)
>       at 
> org.apache.felix.framework.BundleContextImpl.ungetService(BundleContextImpl.java:455)
>       at 
> org.apache.sling.models.impl.injectors.OSGiServiceInjector$Callback.onDisposed(OSGiServiceInjector.java:203)
>  [org.apache.sling.models.impl:1.4.16]
>       at 
> org.apache.sling.models.impl.ModelAdapterFactory$DisposalCallbackRegistryImpl.onDisposed(ModelAdapterFactory.java:143)
>  [org.apache.sling.models.impl:1.4.16]
>       at 
> org.apache.sling.models.impl.ModelAdapterFactory.clearDisposalCallbackRegistryQueue(ModelAdapterFactory.java:214)
>  [org.apache.sling.models.impl:1.4.16]
>       at 
> org.apache.sling.models.impl.ModelAdapterFactory.run(ModelAdapterFactory.java:206)
>  [org.apache.sling.models.impl:1.4.16]
>       at 
> org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:349)
>  [org.apache.sling.commons.scheduler:2.7.12]
>       at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
> [org.apache.sling.commons.scheduler:2.7.12]
>       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>       at java.lang.Thread.run(Unknown Source)
> {code}
> [0]: 
> https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L207



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to