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

动态类因为SpringCGLIB代理 录制了但是回放无法使用从而回放失败 #437

Closed ZHFlys closed 2 months ago

ZHFlys commented 2 months ago

Bug description 动态类配置后录制成功 最新版入库到节点arex.mergeRecord节点 , 但是回放时 先从库将节点序列化成cachedReplayResultMap对象 key是请求api计算的 按照当时录制的方法签名计算的hash 但是取key数据时 通过 MockUtils.methodRequestTypeHash计算的方法签名 包含$$EnhancerBySpringCGLIB$$random$$的序列 导致无法从合并map取出来 这块逻辑应该兼容下 我的临时办法是agent这边重新计算hash 是正则去掉这个后的 如 operationName.replaceAll("\$\$EnhancerBySpringCGLIB\$\$[a-zA-Z0-9]+", "")

Steps to reproduce 在动态类配置后重启录制 然后回放

Expected behavior

在动态节点arex.mergeRecord录制成功入库并且界面能查询到 回放相应也应该成功

What went wrong? 回放错误 查询动态mock数据为null 导致回放失败

Environment

arex-agent-java: 0.4.2

Additional context

mr3 commented 2 months ago

@ZHFlys 感谢反馈,方便贴一下录制下来的数据吗?

ZHFlys commented 2 months ago

image

类似这样的命名 现在我替换后 入库和查询都正则了这个 暂时没问题

mr3 commented 2 months ago

@ZHFlys 感谢回复,你可以提交一个PR修复这个问题。

DanLi39 commented 2 months ago

image

类似这样的命名 现在我替换后 入库和查询都正则了这个 暂时没问题

@ZHFlys This issue has been fixed. The latest code of the main branch can be pulled and used.