HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.36k stars 493 forks source link

Help, the new Controller API interface cannot be hot updated. #544

Open XuxuGood opened 8 months ago

XuxuGood commented 8 months ago

A strange problem was detected today. The specific steps to reproduce are as follows:

There is an initial Controller when the service is started, and the interface does not have hello2. At this time, first access the hello2 interface on the page, and a 404 will be reported:

image image

接着我在Controller添加hello接口,同时变更springboot application.properties中配置,同时热更新这两个文件到extraClasspath目录下。

image image

However, when the hello2 interface is actually accessed again, the error code is still 404, and the interface has not been hot updated.

extraClasspath目录内容如下:

image

Version: java: 8u181 dcevm: 8u181 hotswapagent: 1.4.2-SNAOSHOT

Service start: java -XXaltjvm=dcevm -javaagent:/www/app-preview/hotswapagent-1.4.2-SNAPSHOT.jar=autoHotswap=true,propertiesFilePath=/www/app-preview/hotswap-agent.properties -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8005 -jar /www/app-preview/app/app-preview-push-1.0.0-SNAPSHOT.jar

XuxuGood commented 8 months ago

@skybber Help me~

skybber commented 8 months ago

Unfortunately, I'm not a Spring user at all. Maybe @cvictory or @beiwei30 could help.

beiwei30 commented 3 months ago

@XuxuGood I couldn't reproduce the issue you report.

pls. verify with the attached demo app. I can disable and enable '/greeting2' successfully by commenting out the second method (greeting2) back and forth.

The JVM option I am using is '-XX:HotswapAgent=external -javaagent:/hotswap-agent.jar=autoHotswap=true', and JVM I am using is JBR 17.

demo.tar.gz

@RestController
public class GreetingController {

    private final GreetingService service;

    public GreetingController(GreetingService service) {
        this.service = service;
    }

    @RequestMapping("/greeting")
    public @ResponseBody GreetingResponse greeting() {
        return service.greet();
    }
//
//    @RequestMapping("/greeting2")
//    public @ResponseBody GreetingResponse greeting2() {
//        return service.greet();
//    }
}
cvictory commented 3 months ago

As far as I know, it works well and I do some test about this case. Can you provide a demo ?