Closed jorgheymans closed 7 months ago
Doing some digging. Spring changed the signature of org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#invokeCustomInitMethod
a while ago: https://github.com/spring-projects/spring-framework/commit/41ee23345d72623d18accb9484ce5119403c39d5
So here https://github.com/HotswapProjects/HotswapAgent/blob/93ca7bb48ba9793cd542d29e156e11087e384f02/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/transformers/BeanFactoryTransformer.java#L77 you would need to add support for the new method signature (an extra string parameter was added):
diff --git a/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/transformers/BeanFactoryTransformer.java b/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/transformers/BeanFactoryTransformer.java
index 2341fdec..d2922c0b 100644
--- a/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/transformers/BeanFactoryTransformer.java
+++ b/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/transformers/BeanFactoryTransformer.java
@@ -76,7 +76,8 @@ public class BeanFactoryTransformer {
// try catch for custom init method
CtMethod invokeCustomInitMethod = clazz.getDeclaredMethod("invokeCustomInitMethod",
new CtClass[] {classPool.get(String.class.getName()), classPool.get("java.lang.Object"),
- classPool.get("org.springframework.beans.factory.support.RootBeanDefinition")});
+ classPool.get("org.springframework.beans.factory.support.RootBeanDefinition"),
+ classPool.get(String.class.getName())});
invokeCustomInitMethod.addCatch(
InitMethodEnhance.catchException("$2", "$$ha$LOGGER", "$e", "invokeCustomInitMethod", false),
classPool.get("java.lang.Throwable"));
Unsure how this needs to be done if you want to support both versions of that class.
I see that there is only a single method invokeCustomInitMethod
in AbstractAutowireCapableBeanFactory
, so the clazz.getDeclaredMethod(methodName)
method of CtClass could be used, so the transformation would not depend on the method parameters.
SNAPSHOT release is also fixed. Thanks for report!
Woah thank you for the quick turn-around on this !
Hi,
I just updated to the latest snapshot release (https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar) , and starting my app i get this:
Using jdk 17.10 from jetbrains, spring boot 3.2.3.
Checking AbstractAutowireCapableBeanFactory, the method is there with this signature:
protected void invokeCustomInitMethod(String beanName, Object bean, RootBeanDefinition mbd, String initMethodName)