arextest / arex-agent-java

Lightweight Java agent for traffic capture and replay, enhancing testing and debugging.
https://doc.arextest.com/
Apache License 2.0
416 stars 83 forks source link

Netty4 server无法记录或者回放 #427

Open jinwik opened 3 months ago

jinwik commented 3 months ago

Steps to reproduce deps: vertx-web 3.9.4

public class ServerVerticle extends AbstractVerticle {
    @Override
    public void start() {
        Router router = Router.router(vertx);
        router.get("/hello").handler(routingContext -> {
            routingContext.response().end(new JsonObject().put("message", "Hello, World!").encode());
        });
        vertx.createHttpServer()
            .requestHandler(router)
            .listen(9998);
    }

    public static void main(String[] args) {
        Vertx.vertx().deployVerticle(ServerVerticle.class.getName());
    }
}

Environment

Compiler: 1.8 arex-agent-java: 0.4.0

Additional context 简单修复: 删除掉RequestTracingHandler:channelReadComplete 在ResponseTracingHandler#invoke方法中 添加 if (ContextManager.needReplay()) { MockUtils.replayBody(mocker); } else if (ContextManager.needRecord()) { MockUtils.recordMocker(mocker); } CaseEventDispatcher.onEvent(CaseEvent.ofExitEvent());