Author: gnodet
Date: Fri Feb 13 14:56:33 2009
New Revision: 744135
URL: http://svn.apache.org/viewvc?rev=744135&view=rev
Log:
Avoid possible NPE (though it needs investigation)
Modified:
servicemix/smx4/nmr/trunk/jbi/osgi/src/main/java/org/apache/servicemix/jbi/osgi/RegistryWrapper.java
Modified:
servicemix/smx4/nmr/trunk/jbi/osgi/src/main/java/org/apache/servicemix/jbi/osgi/RegistryWrapper.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/osgi/src/main/java/org/apache/servicemix/jbi/osgi/RegistryWrapper.java?rev=744135&r1=744134&r2=744135&view=diff
==============================================================================
---
servicemix/smx4/nmr/trunk/jbi/osgi/src/main/java/org/apache/servicemix/jbi/osgi/RegistryWrapper.java
(original)
+++
servicemix/smx4/nmr/trunk/jbi/osgi/src/main/java/org/apache/servicemix/jbi/osgi/RegistryWrapper.java
Fri Feb 13 14:56:33 2009
@@ -28,6 +28,8 @@
import org.apache.servicemix.nmr.api.Reference;
import org.apache.servicemix.nmr.api.Wire;
import org.apache.servicemix.nmr.core.util.MapToDictionary;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -42,6 +44,8 @@
*/
public class RegistryWrapper implements EndpointRegistry {
+ private static final Log LOG = LogFactory.getLog(RegistryWrapper.class);
+
private EndpointRegistry registry;
private BundleContext bundleContext;
private Map<Endpoint, ServiceRegistration> registrations = new
ConcurrentHashMap();
@@ -61,7 +65,11 @@
public void unregister(Endpoint endpoint, Map<String, ?> properties) {
ServiceRegistration reg = registrations.remove(endpoint);
- reg.unregister();
+ if (reg != null) {
+ reg.unregister();
+ } else {
+ LOG.warn("Unregistration failed: the endpoint was not found in
registry: " + endpoint + " (" + properties + ")");
+ }
}
public List<Endpoint> query(Map<String, ?> properties) {