incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1155333 - in /sling/trunk: bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java launchpad/builder/src/main/bundles/list.xml
Date Tue, 09 Aug 2011 12:27:06 GMT
Author: cziegeler
Date: Tue Aug  9 12:27:05 2011
New Revision: 1155333

URL: http://svn.apache.org/viewvc?rev=1155333&view=rev
Log:
SLING-2172 : NPE in DefaultSlingScript#verifySlingBindings

Modified:
    sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java
    sling/trunk/launchpad/builder/src/main/bundles/list.xml

Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java?rev=1155333&r1=1155332&r2=1155333&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java
(original)
+++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java
Tue Aug  9 12:27:05 2011
@@ -19,9 +19,9 @@ package org.apache.sling.scripting.core.
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.script.Bindings;
 import javax.script.ScriptEngine;
@@ -172,8 +172,8 @@ public class SlingScriptAdapterFactory i
     protected void activate(ComponentContext context) {
         this.bundleContext = context.getBundleContext();
 
-        this.genericBindingsValuesProviders = new HashMap<Object, BindingsValuesProvider>();
-        this.langBindingsValuesProviders = new HashMap<String, Map<Object, BindingsValuesProvider>>();
+        this.genericBindingsValuesProviders = new ConcurrentHashMap<Object, BindingsValuesProvider>();
+        this.langBindingsValuesProviders = new ConcurrentHashMap<String, Map<Object,
BindingsValuesProvider>>();
 
         ServiceTrackerCustomizer customizer = new BindingsValuesProviderCustomizer();
 
@@ -208,10 +208,10 @@ public class SlingScriptAdapterFactory i
     }
 
     private Collection<BindingsValuesProvider> getBindingsValuesProviders(ScriptEngineFactory
scriptEngineFactory) {
-        List<BindingsValuesProvider> results = new ArrayList<BindingsValuesProvider>();
+        final List<BindingsValuesProvider> results = new ArrayList<BindingsValuesProvider>();
         results.addAll(genericBindingsValuesProviders.values());
-        for (String name : scriptEngineFactory.getNames()) {
-            Map<Object, BindingsValuesProvider> langProviders = langBindingsValuesProviders.get(name);
+        for (final String name : scriptEngineFactory.getNames()) {
+            final Map<Object, BindingsValuesProvider> langProviders = langBindingsValuesProviders.get(name);
             if (langProviders != null) {
                 results.addAll(langProviders.values());
             }
@@ -222,33 +222,35 @@ public class SlingScriptAdapterFactory i
     private class BindingsValuesProviderCustomizer implements ServiceTrackerCustomizer {
 
         @SuppressWarnings("unchecked")
-        public Object addingService(ServiceReference ref) {
-            String engineName = (String) ref.getProperty(ScriptEngine.NAME);
-            Object serviceId = ref.getProperty(Constants.SERVICE_ID);
+        public Object addingService(final ServiceReference ref) {
+            final String engineName = (String) ref.getProperty(ScriptEngine.NAME);
+            final Object serviceId = ref.getProperty(Constants.SERVICE_ID);
             Object service = bundleContext.getService(ref);
-            if (service instanceof Map) {
-                service = new MapWrappingBindingsValuesProvider((Map<String, Object>)
service);
-            }
-            if (engineName == null || ANY_ENGINE.contains(engineName.toUpperCase())) {
-                genericBindingsValuesProviders.put(serviceId, (BindingsValuesProvider) service);
-            } else {
-                Map<Object, BindingsValuesProvider> langProviders = langBindingsValuesProviders.get(engineName);
-                if (langProviders == null) {
-                    langProviders = new HashMap<Object, BindingsValuesProvider>();
-                    langBindingsValuesProviders.put(engineName, langProviders);
+            if ( service != null ) {
+                if (service instanceof Map) {
+                    service = new MapWrappingBindingsValuesProvider((Map<String, Object>)
service);
                 }
+                if (engineName == null || ANY_ENGINE.contains(engineName.toUpperCase()))
{
+                    genericBindingsValuesProviders.put(serviceId, (BindingsValuesProvider)
service);
+                } else {
+                    Map<Object, BindingsValuesProvider> langProviders = langBindingsValuesProviders.get(engineName);
+                    if (langProviders == null) {
+                        langProviders = new ConcurrentHashMap<Object, BindingsValuesProvider>();
+                        langBindingsValuesProviders.put(engineName, langProviders);
+                    }
 
-                langProviders.put(serviceId, (BindingsValuesProvider) service);
+                    langProviders.put(serviceId, (BindingsValuesProvider) service);
+                }
             }
             return service;
         }
 
-        public void modifiedService(ServiceReference ref, Object service) {
+        public void modifiedService(final ServiceReference ref, final Object service) {
             removedService(ref, service);
             addingService(ref);
         }
 
-        public void removedService(ServiceReference ref, Object service) {
+        public void removedService(final ServiceReference ref, final Object service) {
             Object serviceId = ref.getProperty(Constants.SERVICE_ID);
             if (genericBindingsValuesProviders.remove(serviceId) == null) {
                 for (Map<Object, BindingsValuesProvider> coll : langBindingsValuesProviders.values())
{

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1155333&r1=1155332&r2=1155333&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Tue Aug  9 12:27:05 2011
@@ -160,7 +160,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.core</artifactId>
-            <version>2.0.16</version>
+            <version>2.0.17-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>



Mime
View raw message