incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r951311 - /sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java
Date Fri, 04 Jun 2010 07:34:46 GMT
Author: fmeschbe
Date: Fri Jun  4 07:34:46 2010
New Revision: 951311

URL: http://svn.apache.org/viewvc?rev=951311&view=rev
Log:
SLING-1544 Prevent NullPointer- and IllegalStateExceptions from being thrown from the refreshScriptEngineManager
method (no thread safety yet)

Modified:
    sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java

Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java?rev=951311&r1=951310&r2=951311&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java
(original)
+++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineManagerFactory.java
Fri Jun  4 07:34:46 2010
@@ -78,9 +78,12 @@ public class ScriptEngineManagerFactory 
 
     @SuppressWarnings("unchecked")
     private void refreshScriptEngineManager() {
+
         if (scriptEngineManagerRegistration != null) {
             scriptEngineManagerRegistration.unregister();
+            scriptEngineManagerRegistration = null;
         }
+
         // create (empty) script engine manager
         ClassLoader loader = getClass().getClassLoader();
         SlingScriptEngineManager tmp = new SlingScriptEngineManager(loader);
@@ -97,8 +100,12 @@ public class ScriptEngineManagerFactory 
         }
 
         scriptEngineManager = tmp;
-        scriptEngineManagerRegistration = bundleContext.registerService(ScriptEngineManager.class.getName(),
-                scriptEngineManager, new Hashtable());
+
+        if (bundleContext != null) {
+            scriptEngineManagerRegistration = bundleContext.registerService(
+                ScriptEngineManager.class.getName(), scriptEngineManager,
+                new Hashtable());
+        }
 
         // Log messages to verify which ScriptEngine is actually used
         // for our registered extensions
@@ -210,12 +217,13 @@ public class ScriptEngineManagerFactory 
 
         context.getBundleContext().removeBundleListener(this);
 
-        engineSpiBundles.clear();
-        engineSpiServices.clear();
-        scriptEngineManager = null;
         if (scriptEngineManagerRegistration != null) {
             scriptEngineManagerRegistration.unregister();
+            scriptEngineManagerRegistration = null;
         }
+        engineSpiBundles.clear();
+        engineSpiServices.clear();
+        scriptEngineManager = null;
         if (this.eventAdminTracker != null) {
             this.eventAdminTracker.close();
             this.eventAdminTracker = null;



Mime
View raw message