FELIX-2372 Improve logging for IllegalStateException on service access
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@949675 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
index 69290d4..c5aa5e3 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
@@ -779,14 +779,29 @@
return service;
}
- // otherwise acquire the service and keep it
- service = m_componentManager.getActivator().getBundleContext().getService( serviceReference );
+ // otherwise acquire the service
+ try
+ {
+ service = m_componentManager.getActivator().getBundleContext().getService( serviceReference );
+ }
+ catch ( IllegalStateException ise )
+ {
+ // caused by getService() called on invalid bundle context
+ // or if there is a service reference cycle involving service
+ // factories !
+ m_componentManager.log( LogService.LOG_ERROR, "Failed getting service {0} ({1}/{2,number,#})", new Object[]
+ { m_dependencyMetadata.getName(), m_dependencyMetadata.getInterface(),
+ serviceReference.getProperty( Constants.SERVICE_ID ) }, ise );
+ service = null;
+ }
+
+ // keep the service for latter ungetting
if ( service != null )
{
m_bound.put( serviceReference, service );
}
- // returne the acquired service (may be null of course)
+ // return the acquired service (may be null of course)
return service;
}