You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2017/05/03 21:18:08 UTC
svn commit: r1793718 -
/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
Author: pauls
Date: Wed May 3 21:18:08 2017
New Revision: 1793718
URL: http://svn.apache.org/viewvc?rev=1793718&view=rev
Log:
Synchronize the deactivate with the bundleChanged and check if we are still active when an event occurs (SLING-6640)
Modified:
sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java?rev=1793718&r1=1793717&r2=1793718&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java Wed May 3 21:18:08 2017
@@ -122,13 +122,17 @@ public class ContentLoaderService implem
* @param event The <code>BundleEvent</code> representing the bundle state
* change.
*/
- public void bundleChanged(BundleEvent event) {
+ public synchronized void bundleChanged(BundleEvent event) {
//
// NOTE:
// This is synchronous - take care to not block the system !!
//
+ if (this.bundleContentLoader == null) {
+ return;
+ }
+
Session session = null;
final Bundle bundle = event.getBundle();
switch (event.getType()) {
@@ -139,9 +143,7 @@ public class ContentLoaderService implem
try {
session = this.getSession();
final boolean isUpdate;
- synchronized ( this.updatedBundles ) {
- isUpdate = this.updatedBundles.remove(bundle.getSymbolicName());
- }
+ isUpdate = this.updatedBundles.remove(bundle.getSymbolicName());
bundleContentLoader.registerBundle(session, bundle, isUpdate);
} catch (Throwable t) {
log.error(
@@ -155,9 +157,7 @@ public class ContentLoaderService implem
case BundleEvent.UPDATED:
// we just add the symbolic name to the list of updated bundles
// we will use this info when the new start event is triggered
- synchronized ( this.updatedBundles ) {
- this.updatedBundles.add(bundle.getSymbolicName());
- }
+ this.updatedBundles.add(bundle.getSymbolicName());
break;
case BundleEvent.UNINSTALLED:
try {
@@ -213,7 +213,7 @@ public class ContentLoaderService implem
// ---------- SCR Integration ---------------------------------------------
/** Activates this component, called by SCR before registering as a service */
- protected void activate(ComponentContext componentContext) {
+ protected synchronized void activate(ComponentContext componentContext) {
this.slingId = this.settingsService.getSlingId();
this.bundleContentLoader = new BundleContentLoader(this, contentReaderWhiteboard);
@@ -266,7 +266,7 @@ public class ContentLoaderService implem
}
/** Deactivates this component, called by SCR to take out of service */
- protected void deactivate(ComponentContext componentContext) {
+ protected synchronized void deactivate(ComponentContext componentContext) {
componentContext.getBundleContext().removeBundleListener(this);
if ( this.bundleContentLoader != null ) {