Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11132

Exception handling while clearing OSGiServiceReferences

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Models Implementation 1.5.0
    • Sling Models
    • None

    Description

      "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:

      1. Create a model consisting of OSGiService Injection
      2. Use this model in a page
      3. Open the created page and refresh it couple of time (10-15)
      4. Restart the bundle with model created in step 1
      5. One may see the following exceptions in the logs (after every ~30 seconds to clear up the OSGi service references)
        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)
        

      [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

      Attachments

        Activity

          People

            diru Dirk Rudolph
            sagarmiglani Sagar Miglani
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 5h 50m
                5h 50m