incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r896843 - /sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
Date Thu, 07 Jan 2010 10:33:18 GMT
Author: cziegeler
Date: Thu Jan  7 10:32:32 2010
New Revision: 896843

URL: http://svn.apache.org/viewvc?rev=896843&view=rev
Log:
SLING-1275 : Return value of ComponentContext#locateContext should be checked for null value

Modified:
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java?rev=896843&r1=896842&r2=896843&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
Thu Jan  7 10:32:32 2010
@@ -340,9 +340,11 @@
     protected void registerPostOperation(ServiceReference ref) {
     	String operationName = (String) ref.getProperty(SlingPostOperation.PROP_OPERATION_NAME);
 		SlingPostOperation operation = (SlingPostOperation) this.componentContext.locateService("postOperation",
ref);
-    	synchronized (this.postOperations) {
-			this.postOperations.put(operationName, operation);
-    	}
+		if ( operation != null ) {
+	        synchronized (this.postOperations) {
+	            this.postOperations.put(operationName, operation);
+	        }
+		}
     }
 
     protected void unbindPostOperation(ServiceReference ref) {
@@ -387,8 +389,17 @@
         index = 0;
         for(final ServiceReference current : this.postProcessors) {
             final SlingPostProcessor processor = (SlingPostProcessor) this.componentContext.locateService("postProcessor",
current);
-            this.cachedPostProcessors[index] = processor;
-            index++;
+            if ( processor != null ) {
+                this.cachedPostProcessors[index] = processor;
+                index++;
+            }
+        }
+        if ( index < this.cachedPostProcessors.length ) {
+            SlingPostProcessor[] oldArray = this.cachedPostProcessors;
+            this.cachedPostProcessors = new SlingPostProcessor[index];
+            for(int i=0;i<index;i++) {
+                this.cachedPostProcessors[i] = oldArray[i];
+            }
         }
     }
 }



Mime
View raw message