You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2018/01/30 23:04:08 UTC
svn commit: r1822715 -
/aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java
Author: gnodet
Date: Tue Jan 30 23:04:08 2018
New Revision: 1822715
URL: http://svn.apache.org/viewvc?rev=1822715&view=rev
Log:
[ARIES-1436] cm:managed-component destroy-method will only be called when it has a single integer argument
Modified:
aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java
Modified: aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java?rev=1822715&r1=1822714&r2=1822715&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java (original)
+++ aries/trunk/blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedServiceFactory.java Tue Jan 30 23:04:08 2018
@@ -187,10 +187,10 @@ public class CmManagedServiceFactory ext
return null;
}
- private Method findDestroyMethod(Class clazz) {
+ private Method findDestroyMethod(Class clazz, Class... args) {
Method method = null;
if (componentDestroyMethod != null && componentDestroyMethod.length() > 0) {
- List<Method> methods = ReflectionUtils.findCompatibleMethods(clazz, componentDestroyMethod, new Class [] { int.class });
+ List<Method> methods = ReflectionUtils.findCompatibleMethods(clazz, componentDestroyMethod, args);
if (methods != null && !methods.isEmpty()) {
method = methods.get(0);
}
@@ -212,13 +212,22 @@ public class CmManagedServiceFactory ext
}
protected void doDestroy(Object service, Dictionary properties, int code) throws Exception {
- Method method = findDestroyMethod(service.getClass());
+ Method method = findDestroyMethod(service.getClass(), int.class);
if (method != null) {
try {
- method.invoke(service, new Object [] { code });
+ method.invoke(service, code);
} catch (Exception e) {
LOGGER.info("Error destroying component", e);
}
+ } else {
+ method = findDestroyMethod(service.getClass());
+ if (method != null) {
+ try {
+ method.invoke(service);
+ } catch (Exception e) {
+ LOGGER.info("Error destroying component", e);
+ }
+ }
}
}