Author: rwesten
Date: Tue Jun 21 08:30:56 2011
New Revision: 1137905

URL: http://svn.apache.org/viewvc?rev=1137905&view=rev
Log:
ContextHelper no longer throws a NPE in the case that a requested service is 
not present. This now allows correctly to request optional dependences.

Modified:
    
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java

Modified: 
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java?rev=1137905&r1=1137904&r2=1137905&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java
 (original)
+++ 
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java
 Tue Jun 21 08:30:56 2011
@@ -25,7 +25,11 @@ public class ContextHelper {
         ServiceReference reference = 
bundleContext.getServiceReference(clazz.getName());
         //TODO: returning the service will cause the service reference not to 
be
         //  released bundleContext.ungetService(reference) will not be called!
-        return (T) bundleContext.getService(reference);
+        if(reference != null){
+            return (T) bundleContext.getService(reference);
+        } else {
+            return null;
+        }
     }
 
 }


Reply via email to