Elia Colombo created SLING-12315:
------------------------------------
Summary: A race condition leads to failing resource-bundle
registration during deactivation
Key: SLING-12315
URL: https://issues.apache.org/jira/browse/SLING-12315
Project: Sling
Issue Type: Bug
Components: i18n
Reporter: Elia Colombo
The following exception was observed:
{code:java}
[sling-default-5-ResourceBundleProvider: reload all resource bundles]
org.apache.sling.commons.scheduler.impl.QuartzScheduler Exception during job
execution of job
'org.apache.sling.i18n.impl.JcrResourceBundleProvider$1@688bc8e' with name
'ResourceBundleProvider: reload all resource bundles' : Cannot invoke
"org.osgi.framework.BundleContext.registerService(java.lang.Class, Object,
java.util.Dictionary)" because "this.bundleContext" is
nulljava.lang.NullPointerException: Cannot invoke
"org.osgi.framework.BundleContext.registerService(java.lang.Class, Object,
java.util.Dictionary)" because "this.bundleContext" is null at
org.apache.sling.i18n.impl.JcrResourceBundleProvider.registerResourceBundle(JcrResourceBundleProvider.java:532)
[org.apache.sling.i18n:2.6.2]{code}
During the deactivation of JcrResourceBundleProvider, ReloadBundle jobs that
are still running can try to register new resourceBundles. This fails, if
deactivate already set bundleContext to null.
Proposed solution:
* use bundleContext as cancel flag during deactivation (bundleContext=null)
* prevent new registration of resources during deactivation (necessary)
* prevent processing of new onChange events during deactivation (improvement)
* prevent scheduling of new bundle reloading jobs during deactivation
(improvement)
* execute clearCache after setting bundleContext to null, to prevent new
registrations (improvement)
BundleContext can be used as cancel flag, since conveniently it is anyway set
to null during deactivation. New registrations can be effectively avoided by
checking bundleContext==null before any registration within a synchronized
block.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)